Php file upload error I used this code to upload files successfully in WINDOWS, but failed in LINUX. please help me to see why. the following code is: ----u1.htm ---- & lt; formenctype & quot; multipartform-data & quot; name & quot; submitform & quot; action & quot; u1.php & quot; m php file upload error
I used this code to upload files successfully in WINDOWS, but failed in LINUX. please help me to see why. The following is the code:
----U1.htm ----
---- U1.php ----
$ Uploadaction = 0;
$ Timelimit = 0;
Set_time_limit ($ timelimit );
$ Uploaddir = '/root/file /';
$ Uploadfile = $ uploaddir. $ _ FILES ['userfile'] ['name'];
$ Tmpfile = $ _ FILES ['userfile'] ['tmp _ name'];
$ File_size = $ _ FILES ['userfile'] ['size'];
$ Errno = $ _ FILES ['userfile'] ['error'];
Echo "The uploadfile is $ uploadfile ";
Echo "The tmpfile is $ tmpfile ";
If (! File_exists ($ uploadfile ))
{
If (move_uploaded_file ($ tmpfile, $ uploadfile ))
{
Echo "The file $ uploadfile ($ strfilesize) upload successful! ";
}
Else
{
Echo "The file $ uploadfile upload failed (error code: $ errno )";
}
}
Set_time_limit (30 );
?>
The error after running is: upload failed (error code: 0)
------ Solution --------------------
There is no problem with your program. it should be a problem with the php. ini configuration file.
------ Solution --------------------
Chmod ($ uploaddir, "777 ")
File permission .....
------ Solution --------------------
$ Errno = $ _ FILES ['userfile'] ['error'];
The value is 0. If no error occurs, the file is uploaded successfully.
Check whether the parameter path in move_uploaded_file ($ tmpfile, $ uploadfile) is correct and has the read/write permission.
------ Solution --------------------
/Tmp has space?
Is selinux disabled?