Php file upload problems remain unsolved after permission modification

Source: Internet
Author: User
Tags php file upload
After modifying the permission limit, you still cannot determine whether ex.html provides the foreground Upload control: & lt; html & gt; & lt; body & gt; & lt; formaction & quot; ex. php & quot; method & quot; post & quot; enctype & quot; multipartform-data & quot; & gt; & lt; labelfor & q php file upload problems, the permission is not resolved after modification.
Ex.html provides the front-end Upload control:





Ex. php background handler:
If ($ _ FILES ["file"] ["error"]> 0)
{
Echo "Error:". $ _ FILES ["file"] ["error"]."
";
}
Else
{

If ($ _ FILES ["file"] ["type"] = "application/pdf ")
{
If (file_exists ("/home/sss/document/". $ _ FILES ["file"] ["name"])
{
Echo $ _ FILES ["file"] ["naem"]. "already exists ";
}
Else
{
Move_uploaded_file ($ _ FILES ["file"] ["tmp_name"], "/home/sss/document /". $ _ FILES ["file"] ["name"]);
Echo "Stored in:". "/home/sss/document/". $ _ FILES ["file"] ["name"];
}
}
}
?>
Error message:
/Warning: move_uploaded_file (/home/php Upload file): failed to open stream: Permission denied in/var/www/html/php/practice/ex. php on line 25 Warning: move_uploaded_file (): unable to move '/tmp/php1GtkFY' to '/home/sss/documentation/abc.pdf' in/var/www/html/php/practice/ex. php on line 25
The document permission is modified to 777. if you still have any questions, please advise.

------ Solution --------------------
Modify/home/sss/document permissions to read/write.
That is, chmod ('/home/sss/documentation', 0666 );

This directory is out of the web scope, and the operating system may not allow anonymous users to grant execution permissions.
------ Solution --------------------
How can you have three files?
1. Upload files to/home/php
2./tmp/php1GtkFY
3./home/sss/document/abc.pdf
Which of the following is a file?

If you upload a/home/php file upload:
$ _ FILES ["file"] ["name"]: upload a file on PHP
$ _ FILES ["file"] ["tmp_name"]: php1GtkFY
Where did abc.pdf come from? There is no rename in your code ?!!

If you are using Linux, use "./home/sss/document/". Otherwise, the system will start from the root directory.
------ Solution --------------------
Maybe apache didn't give you the corresponding permissions. Modify the apache configuration file and grant the corresponding directory permissions.
------ Solution --------------------
I suspect your path is wrong.
The path of the target file is removed.

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.