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.