Php files always fail to be uploaded. how can this problem be solved?

Source: Internet
Author: User
Php files always fail to be uploaded; php files always fail to be uploaded.
Http://www.w3school.com.cn/php/php_file_upload.asp
I looked at this example, but when I was elected a file and clicked Upload, Error 6 appeared. I was in php. in ini, set upload_tmp_dir to upload_tmp_dir = "C: \ WX" and click upload to display the Invalid file. the file cannot be uploaded. Share:
------ Solution --------------------
In general, the upload and storage directories cannot be written. You have to set it up.
------ Solution --------------------
Index.html code

Http://www.w3.org/TR/html4/loose.dtd>



Untitled Document










Upload_file.php code:

if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . " ";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . " ";
  echo "Type: " . $_FILES["file"]["type"] . " ";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb ";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }
?>


------ Solution --------------------
You do not need to modify the content in php. ini. restore it and try again.
------ Solution --------------------
Reference:
Quote: reference:

Index.html code

Http://www.w3.org/TR/html4/loose.dtd>



Untitled Document










Upload_file.php code:

if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . " ";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . " ";
  echo "Type: " . $_FILES["file"]["type"] . " ";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb ";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }
?>



$ _ FILES ["file"]
Print the variable and check what it is.

print_r($_FILES["file"]);exit;

------ Solution --------------------
Error: 6
Indicates that the uploaded file does not exist.

You 'd better set upload_tmp_dir to D: that is, later Drive
Because C: Generally, the drive is set to prohibit file operations by anonymous users.
------ Solution --------------------
$ _ FILES ['file'] ['error']
The value is 0. If no error occurs, the file is uploaded successfully.

The value is 1, and the uploaded file exceeds the limit of the upload_max_filesize option in php. ini.

The value is 2, and the size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.

The value is 3, and only part of the file is uploaded.

The value is 4 and no file is uploaded.

The value is 6 and the temporary folder cannot be found. PHP 4.3.10 and PHP 5.0.3 are introduced.

If the value is 7, the file fails to be written. PHP 5.1.0 is introduced.

If an error is reported, the temporary folder does not have the write permission or does not exist.

------ Solution --------------------
Http://www.w3.org/TR/html4/loose.dtd>



Untitled Document

 

Enctype = "multipart/form-data">
Filename:
 

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.