ironj221
05-01-2009, 11:47 PM
I have had a file upload on my site for about a year, and all of a sudden it stopped working. I identified the problem is that the tmp_name is empty. I have way more than enough space on the server, so that isn't the problem.
if($_FILES['userfile']['name'] != "") {
$allowed_filetypes = array('.gif','.jpg','.jpeg','.png','.JPG','.GIF','.JPEG','.PNG');
$max_filesize = 2097152; // (currently 2.0MB).
$upload_path = './bgimages/';
$filename = $_FILES['userfile']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
list($width, $height, $type, $attr) = getimagesize($_FILES['userfile']['tmp_name'] );
if ($width > 1920 || $height > 1200)
$error = "Maximum width and height exceeded. The maximum size is 190x150.";
if(!in_array($ext,$allowed_filetypes))
$error = "The file you attempted to upload is not allowed.";
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
$error = "The file you attempted to upload is too large. 2MB maximum.";
if(!is_writable($upload_path))
$error = "You cannot upload to the specified directory, please CHMOD it to 777.";
if (empty($error)) {
$filename = $user_id . $_FILES['userfile']['name'];
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
$msg = "Your file upload was successful.";
else
$error = "There was an error during the file upload. Please try again later or contact support.";
}
Running this gives me the error: Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /patchto/public_html/settings/createtheme.php on line 68
I also have the correct multipart/form-data enctype on the form.
Any ideas what would cause it to suddenly stop working? I'm thinking it has to be something with the server?
if($_FILES['userfile']['name'] != "") {
$allowed_filetypes = array('.gif','.jpg','.jpeg','.png','.JPG','.GIF','.JPEG','.PNG');
$max_filesize = 2097152; // (currently 2.0MB).
$upload_path = './bgimages/';
$filename = $_FILES['userfile']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
list($width, $height, $type, $attr) = getimagesize($_FILES['userfile']['tmp_name'] );
if ($width > 1920 || $height > 1200)
$error = "Maximum width and height exceeded. The maximum size is 190x150.";
if(!in_array($ext,$allowed_filetypes))
$error = "The file you attempted to upload is not allowed.";
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
$error = "The file you attempted to upload is too large. 2MB maximum.";
if(!is_writable($upload_path))
$error = "You cannot upload to the specified directory, please CHMOD it to 777.";
if (empty($error)) {
$filename = $user_id . $_FILES['userfile']['name'];
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
$msg = "Your file upload was successful.";
else
$error = "There was an error during the file upload. Please try again later or contact support.";
}
Running this gives me the error: Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /patchto/public_html/settings/createtheme.php on line 68
I also have the correct multipart/form-data enctype on the form.
Any ideas what would cause it to suddenly stop working? I'm thinking it has to be something with the server?