Ok, this is your script:
<?php
// Receiving variables
@$CONTACT_EMAIL_ADRESS = addslashes($_POST['CONTACT_EMAIL_ADRESS']);
@$COMMENT = addslashes($_POST['COMMENT']);
@$TITTLE = addslashes($_POST['TITTLE']);
@$IMAGE_Name = $_FILES['IMAGE']['name'];
@$IMAGE_Size = $_FILES['IMAGE']['size'];
@$IMAGE_Temp = $_FILES['IMAGE']['tmp_name'];
@$IMAGE_Mime_Type = $_FILES['IMAGE']['type'];
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
// Validation
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $CONTACT_EMAIL_ADRESS))
{
header("Location: upload_errortype2.html");
exit;
}
if (strlen($CONTACT_EMAIL_ADRESS) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if (strlen($COMMENT) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if (strlen($TITTLE) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if ($IMAGE_Size>0)
{
if( $IMAGE_Size >50000)
{
//delete file
unlink($IMAGE_Temp);
header("Location: upload_errortype3.html");
exit;
}
if( $IMAGE_Mime_Type != "image/gif" AND $IMAGE_Mime_Type != "image/jpeg" AND $IMAGE_Mime_Type != "image/png" AND $IMAGE_Mime_Type != "image/tiff" ) { unlink($IMAGE_Temp); header("Location: upload_errortype4.html"); exit; }
$uploadFile = "upload/".$IMAGE_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $IMAGE_Temp , $uploadFile);
chmod($uploadFile, 0644);
$IMAGE_URL = "http://www.yourdomain.co.uk/upload/".$IMAGE_Name ;
}
// Find Server date and Time
$date = date("l jS F Y, g:i A");
// Find Browser and IPaddress
$browser =$_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
//Sending Email to form owner
$pfw_header = "From: $CONTACT_EMAIL_ADRESS\n"
. "Reply-To: $CONTACT_EMAIL_ADRESS\n";
$pfw_subject = "New Picture Upload";
$pfw_email_to = "
youremail@yourdomain.co.uk";
$pfw_message = "A new Picture has been uploaded\n"
. "-----------------------------------------\n"
. "\n"
. "\n"
. "CONTACT_EMAIL_ADRESS: $CONTACT_EMAIL_ADRESS\n"
. "COMMENT: $COMMENT\n"
. "TITTLE: $TITTLE\n"
. "IMAGE: $IMAGE_URL\n"
. " \n"
. "Date of upload : $date\n"
. "Browser : $browser\n"
. "IP address : $ip\n";
*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thankyou_page.html");
?>
Please follow these steps:
1. Copy and paste this code in Notepad. Change your email address, with one of your vodahost account emails. Go to "Save As", choose File Type "All Files", and save it as "upload1.php" . Upload it on the server.
2. Create a folder in your public_html, called "upload". This is where all the images will be stored.
Set permissions for this folder in 777
3. Create two more error pages: "upload_errortype3.html" and "upload_errortype4.html" the first for File size exceeding 50 kb (this is the limit i have put, you may change it to be 3 - 5 or what you want kb (The size is in Bytes) and the second for wrong file type (i have put jpeg, png, tiff and gif as acceptable types)
Test the script and let me know.