Php file Upload exception-php Tutorial

Source: Internet
Author: User
Tags php file upload
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.