PHP Upload problems

Source: Internet
Author: User
PHP Upload problem: the html document is correct. here we only talk about how to process uploads. & lt ;? Php // echo & quot; & lt; pre & gt; & quot; // print_r ($ _ FILES); // echo & quot; & lt; pre & gt; & quot; $ file_size = $ PHP Upload problems
There is no error in the html document. here we only talk about processing uploads.
// Echo"
";
// Print_r ($ _ FILES );
// Echo"
";
$ File_size = $ _ FILES ['myfile'] ['size'];
If ($ file_size> 2*1024*1024 ){
Echo "the file is too large to upload files larger than 2 MB ";
Exit ();
}
If (is_uploaded_file ($ _ FILES ['myfile'] ['tmp _ name']) {
// Transfer the file to the desired directory
$ Uploaded_file = $ _ FILES ['myfile'] ['tmp _ name'];
$ Moveto_file = $ _ SERVER ['document _ root']. "/shenwenjian/". $ _ FILES ['myfile'] ['name'];
$ Temp = move_uploaded_file ($ uploaded_file, iconv ("UTF-8", "gb2312", $ moveto_file ));
// Echo $ uploaded_file. "|". $ moveto_file;
If ($ temp ){
Echo "Upload successful! ";
}
Else {
Echo "Upload failed! ";
}
} Else {
Echo "Upload failed! ";
}

?>
When I upload a txt file in the active image format, the following error occurs:
Warning: move_uploaded_file (D:/AppServ/www/shenwenjian/) [function. move-uploaded-file]: failed to open stream: Permission denied in D: \ AppServ \ www \ shenwenjian \ uploadprocess. php on line 14

Warning: move_uploaded_file () [function. move-uploaded-file]: Unable to move 'C: \ Windows \ TEMP \ phpB4EB. tmp 'to 'D:/AppServ/www/shenwenjian/' in D: \ AppServ \ www \ shenwenjian \ uploadprocess. php on line 14

It should not be a server limit. if it is a size limit, an error should be reported directly. this is very small for my Word documents.

------ Solution --------------------
Print_r ($ _ FILES );

Upload two types of files and paste the results
------ Solution --------------------
Create another folder under the root directory, set its permission to 757, and then move the file into it.

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.