Pls help me in this php code.. i wann make the page that upload only images..but below php code uploads all kind of file..so what changes should i make so that the it uploads images only....
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<form method="POST" enctype="multipart/form-data" action="upload.php">
<p><input type="text" name="mail" size="20"></p>
<p><input type="file" name="upload" size="20" class="formbox"><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
<?PHP
----------------------------------------------------
-----
----- HELP ME
-----
----------------------------------------------------
error_reporting(7);
if (isset($SERVER['HTTP_X_FORWARDED_FOR'])) {
$ClientIP = $SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ClientIP = $_SERVER['REMOTE_ADDR'];
}
RegisterGlobals OFF
$FTGmail = $POST['mail'];
$FTGupload = $FILES['upload']['name'];
if (get_magic_quotes_gpc) {
$FTGmail = stripslashes($FTGmail);
}
Redirect user to the error page
if ($validationFailed == true) {
header("Location: error.html");
exit;
}
Email to Form Owner
$emailTo = '"Monika" <monin12001@hotmail.com>';
$emailSubject = "attachment.......from $FTGmail";
$emailSubject = preg_replace('/[\x00-\x1F]/', '', $emailSubject);
$emailFrom = "$FTGmail";
$emailFrom = preg_replace('/[\x00-\x1F]/', '', $emailFrom);
$emailHeader = "From: $emailFrom\n"
. "Reply-To: $emailFrom\n"
. "MIME-Version: 1.0\n"
. "Content-Type: multipart/mixed; boundary=\"FTG_BOUNDRY\"\n"
. "X-Sender: $emailFrom\n"
. "X-Mailer: PHP\n"
. "X-Priority: 3\n"
. "Return-Path: $emailFrom\n"
. "This is a multi-part Content MIME format.\n";
$emailBody = "--FTG_BOUNDRY\n"
. "Content-Type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-Transfer-Encoding: quoted-printable\n"
. "\n"
. "mail: $FTGmail\n"
. "upload: $FTGupload\n"
. "\n"
. ""
. "\n";
if (file_exists($_FILES['upload']['tmp_name']) === true) {
$fileName = $_FILES['upload']['tmp_name'];
$fileHandle = fopen($fileName, 'r');
$fileAttach = fread($fileHandle, filesize ($fileName));
fclose($fileHandle);
$fileAttach = chunk_split(base64_encode($fileAttach));
$emailBody .= "--FTG_BOUNDRY\n"
. "Content-Type: " . $FILES['upload']['type'] . "; name=\"" . $FILES['upload']['name'] . "\"\n"
. "Content-disposition: attachment\n"
. "Content-transfer-encoding: base64\n"
. "\n"
. "$fileAttach\n"
. "\n";
}
$emailBody .= "--FTG_BOUNDRY--\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
Redirect user to success page
header("Location: success.html");
exit;
End of PHP script
?>