Trouble with move_uploaded_file()
Posted: Thu Aug 24, 2006 8:13 am
I am migrating an app to a new server and I'm having trouble getting the move_uploaded_file function to work on the new server.
I did a print_r($_FILES) and I know the file to be uploaded is valid and is in the max_upload_size limit. However, move_uploaded_file() returns false with no error message and I can't figure out why.
Here is a link to my phpinfo();
http://www.ucl.ac.uk/eastman/nutrident/check.php
And here is the pertinent code...
$_SESSION["uploadError"] always returns "Upload Error!".
Is there something wrong with my php.ini?
Thanks.
I did a print_r($_FILES) and I know the file to be uploaded is valid and is in the max_upload_size limit. However, move_uploaded_file() returns false with no error message and I can't figure out why.
Here is a link to my phpinfo();
http://www.ucl.ac.uk/eastman/nutrident/check.php
And here is the pertinent code...
Code: Select all
$destdir = 'filestore/';
$fileNameArray = explode(".",$_FILES["userfile"]["name"]);
$fileBase = $fileNameArray[0];
$ext = $fileNameArray[1];
$destfile = $destdir.$fileBase.".".$ext;
switch($_FILES["userfile"]["error"])
{
case 0:
if(move_uploaded_file($_FILES["userfile"]["tmp_name"], $destfile))
{
//Change the file permissions
chmod($destfile, 0755);
}
else
$_SESSION["uploadError"] = "<span>Upload error!</span>";
break;
case 1:
$_SESSION["uploadError"] = "<span>Max size exceeded. Please upload a smaller file.</span>";
break;
case 2:
case 3:
$_SESSION["uploadError"] = "<span>File Upload Incomplete! Please Try Again.</span>\n";
break;
case 4:
$_SESSION["uploadError"] = "<span>Please select a valid file.</span>\n";
break;
}Is there something wrong with my php.ini?
Thanks.