php code is not catching errors
Posted: Sun Jan 25, 2004 4:44 am
Anybody have any suggestion as to why this code is not catching errors
Code: Select all
<?php
if ($HTTP_POST_VARS['submit']) {
print ($bandname);
if (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) {
$error = "You did not upload a file!";
unlink($HTTP_POST_FILES['file']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
//a file was uploaded
$maxfilesize=500240;
if ($HTTP_POST_FILES['file']['size'] > $maxfilesize) {
$error = "photo is too large";
unlink($HTTP_POST_FILES['file']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
if ($HTTP_POST_FILES['file']['type'] != "image/gif" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg") {
$error = "This file type is not allowed";
unlink($HTTP_POST_FILES['file']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
//File has passed all validation, copy it to the final destination and remove the temporary file:
copy($HTTP_POST_FILES['file']['tmp_name'],"/home/httpd/vhosts/springscream.com/httpdocs/ssbandphotoupload/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
if (!is_uploaded_file($HTTP_POST_FILES['file2']['tmp_name'])) {
$error = "Got it. Thanks!";
mail("wade@springscream.com","Photos from $bandname","Photos $file, $file2, $file3 has be sent to http://wwww.springscream.com/uploadbandphotos/","From: $email");
print ", your photo(s) has been successfully uploaded!收到了謝謝!";
exit;
// assign error message, remove uploaded file, redisplay form.
} else {
if ($HTTP_POST_FILES['file2']['size'] > $maxfilesize) {
$error = "photo2 is too large";
unlink($HTTP_POST_FILES['file2']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
if ($HTTP_POST_FILES['file2']['type'] != "image/gif" AND $HTTP_POST_FILES['file2']['type'] != "image/pjpeg") {
$error = "This file type is not allowed";
unlink($HTTP_POST_FILES['file2']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
//File has passed all validation, copy it to the final destination and remove the temporary file:
copy($HTTP_POST_FILES['file2']['tmp_name'],"/home/httpd/vhosts/springscream.com/httpdocs/ssbandphotoupload/".$HTTP_POST_FILES['file2']['name']);
unlink($HTTP_POST_FILES['file2']['tmp_name']);
if (!is_uploaded_file($HTTP_POST_FILES['file3']['tmp_name'])) {
$error = "Got it. Thanks!";
mail("wade@springscream.com","Photos from $bandname","Photos $file, $file2, $file3 has be sent to http://wwww.springscream.com/uploadbandphotos/","From: $email");
print ", your photo(s) has been successfully uploaded!收到了謝謝!!";
exit;
} else {
if ($HTTP_POST_FILES['file3']['size'] > $maxfilesize) {
$error = "photo3 is too large";
unlink($HTTP_POST_FILES['file3']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
if ($HTTP_POST_FILES['file3']['type'] != "image/gif" AND $HTTP_POST_FILES['file3']['type'] != "image/pjpeg") {
$error = "This file type is not allowed";
unlink($HTTP_POST_FILES['file3']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
//File has passed all validation, copy it to the final destination and remove the temporary file:
copy($HTTP_POST_FILES['file3']['tmp_name'],"/home/httpd/vhosts/springscream.com/httpdocs/ssbandphotoupload/".$HTTP_POST_FILES['file3']['name']);
unlink($HTTP_POST_FILES['file3']['tmp_name']);
mail("wade@springscream.com","Photos from $bandname","Photos $file, $file2, $file3 has be sent to http://wwww.springscream.com/uploadbandphotos/","From: $email");
print ", your photos and logos have been successfully uploaded!. 收到了謝謝!!!<A HREF="index.htm" TARGET="_blank">Home</A> ";
echo "<A HREF="index.htm" TARGET="_blank">Home</A>";
exit;
}
}
}
}
}
}
}
}
}
}
?>
<html>
<head>
<title>Spring Scream Band Photos</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="Layer1" style="position:absolute; left:23px; top:341px; width:450px; height:227px; z-index:1">
<form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
<div align="center">
<table width="81%" border="1">
<tr>
<td>
<div align="center">
<p align="center">Your Band Name 你的團名
<input type="text" name="bandname" size="40" maxlength="70">
</p>
<p align="center">Your Band Email你團的email
<input name="email" type="text" id="email" size="30" maxlength="30">
<br>
<br>
photo1.....
<input type="file" name="file">
</p>
<p align="center"> photo2 .....
<input type="file" name="file2">
</p>
<p align="center"><font size="3">LOGO....</font>
<input type="file" name="file3">
</p>
<p align="center"><br>
<input type="submit" name="submit" value="send">
</p>
</div>
</td>
</tr>
</table>
</div>
</form>
</div>
<div id="Layer2" style="position:absolute; left:37px; top:23px; width:424px; height:241px; z-index:2">
<p align="center"><font size="4">Upload Your Band Photos Here.....上 傳 你 樂 團 的 照 片 在 這 邊.....</font></p>
<p align="center"><font size="4">Photo file format must be <font color="#FF9900">.jpg</font>
or <font color="#FF9900">.gif</font> and must be under <font color="#FF9900">200kb</font>
in size.可 用 的 格 式 是 <font color="#FF9900">.jpg</font>和<font color="#FF9900">.gif</font>和 大 小 不 可 以 超 過<font color="#FF9900">200kb</font></font></p>
<p align="center">Remember to make sure that the photos' filename is your<strong><font color="#FF9900">
Band Name</font></strong>. 不 要 忘 記 把 你 們 照 片 的 檔 名 改 到 你 們 的<font color="#FF9900">團名</font></p>
<p align="center">And name them with numbers like this.......</p>
<p align="center"><font color="#000000">Ex: dribdas1.jpg, dribdas2.jpg, dribdaslogo.jpg
例 如 :蘿 蔔 腿 1.jpg, 蘿 蔔 腿 2.jpg, 蘿 蔔 腿 logo.jpg</font></p>
<p align="center"> </p>
</div>
</body>
</html>