I had an upload script that used to work perfect but all of a sudden it stopped working. I think my Server admin made some changes.
please help me as I am stuck. It is causing errors:
//user defined variables
$abpath = "seller_images"; //Absolute path to where images are uploaded. No trailing slash
$sizelim = "no"; //Do you want size limit, yes or no
$size = "2500000"; //What do you want size limited to be if there is one
$number_of_uploads = 1; //Number of uploads to occur
if ($_REQUEST['submitted']){ // Begin processing portion of script
//all image types to upload
$cert1 = "image/pjpeg"; //Jpeg type 1
$cert2 = "image/jpeg"; //Jpeg type 2
$cert3 = "image/gif"; //Gif type
$cert4 = "image/ief"; //Ief type
$cert5 = "image/png"; //Png type
$cert6 = "image/tiff"; //Tiff type
$cert7 = "image/bmp"; //Bmp Type
$cert8 = "image/vnd.wap.wbmp"; //Wbmp type
$cert9 = "image/x-cmu-raster"; //Ras type
$cert10 = "image/x-x-portable-anymap"; //Pnm type
$cert11 = "image/x-portable-bitmap"; //Pbm type
$cert12 = "image/x-portable-graymap"; //Pgm type
$cert13 = "image/x-portable-pixmap"; //Ppm type
$cert14 = "image/x-rgb"; //Rgb type
$cert15 = "image/x-xbitmap"; //Xbm type
$cert16 = "image/x-xpixmap"; //Xpm type
$cert17 = "image/x-xwindowdump"; //Xwd type
$log = "";
for ($i=0; $i<$number_of_uploads; $i++) {
//checks if file exists
if ($_FILES['img']['name'][$i] == "") {
$log .= "No file selected for upload $i<br>";
}
if ($_FILES['img']['name'][$i] != "") {
//checks if file exists
if (file_exists("$abpath/$_FILES['img']['name'][$i]")) {
$log .= "File $i already existed<br>";
} else {
//checks if files to big
if (($sizelim == "yes") && ($_FILES['img']['size'][$i] > $size)) {
$log .= "File $i was too big<br>";
} else {
//Checks if file is an image
if (($_FILES['img']['type'][$i] == $cert1) or ($_FILES['img']['type'][$i]== $cert2) or ($_FILES['img']['type'][$i] == $cert3) or ($_FILES['img']['type'][$i] == $cert4) or ($_FILES['img']['type'][$i] == $cert5) or ($_FILES['img']['type'][$i] == $cert6) or ($_FILES['img']['type'][$i] == $cert7) or ($_FILES['img']['type'][$i] == $cert8) or ($_FILES['img']['type'][$i] == $cert9) or ($_FILES['img']['type'][$i] == $cert10) or ($_FILES['img']['type'][$i] == $cert11) or ($_FILES['img']['type'][$i] == $cert12) or ($_FILES['img']['type'][$i] == $cert13) or ($_FILES['img']['type'][$i] == $cert14) or ($_FILES['img']['type'][$i]== $cert15) or ($_FILES['img']['type'][$i]== $cert16) or ($_FILES['img']['type'][$i] == $cert17)) {
@copy($_FILES['img'][$i], "$abpath/$_FILES['img']['name'][$i]") or $log .= "Couldn't copy image 1 to server<br>";
if (file_exists("$abpath/$_FILES['img']['name'][$i]")) {
$log .= "File $i was uploaded<br>";
//lets rename the file so it can be organized in the folder
$old_file = "$abpath/$_FILES['img']['name'][$i]";
$new_file = "$abpath/scott".$i.".gif";
rename($old_file,$new_file);
}
} else {
$log .= "File $i is not an image<br>";
}
}
}
}
}
?>
<html>
<head>
<title>Image Report</title>
</head>
<body>
<p>Log:<br>
<?
echo "$log";
?>
</p>
<body>
</html>
<?
exit;
} // End processing portion of script
?>
<html>
<head>
<title>Upload Image</title>
</head>
<body>
<form method=POST action=uploadfile.php enctype=multipart/form-data>
<p>Files to upload:<br>
<?
for ($j=0; $j<$number_of_uploads; $j++) {
print($j);
?>
<input type=file name=img[] size=30><br>
<?
}
?>
<input type="hidden" name="submitted" value="true">
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
is there a better way to do this ? Is ther a better script. thanks