PHP Data upload

Source: Internet
Author: User
PHP File Upload

You must ensure that the properties of the server destination folder are writable: chmod 777-r dir

?

Main steps:
1, according to the set location in the Web page, self-built a folder for storing files Cyupload
2, modify the Cyupload permissions, into the/tmp folder, chmod 777 Cyupload-r
3, refer to the??? of http://www.w3schools.com/php/php_file_upload.asp Code to establish upload.html and upload.php, respectively
4, according to the requirements of the upload.php in the Judgment statement modified
5, modify the php.ini file, modify the upload file size limit.
File_uploads = on; switch to allow uploading of files over HTTP. The default is on, which is open
Upload_tmp_dir; files uploaded to the server where temporary files are stored, if not specified, will use the system default temporary folder
Upload_max_filesize = 200m; Hope business, that is, the maximum size allowed to upload files. Default is 2M
Post_max_size = 200m; The maximum value that can be received by the form Post to PHP, including all values in the form. Default is 8M
Generally, after setting the above four parameters, uploading <=8m files is not a problem, in the network normal situation.
However, if you want to upload a large volume of >8m files, only set the above four items will certainly be able to pass.
Further configure the following parameters
Max_execution_time = 0;
Max_input_time = 2400; The maximum time required for each PHP page to receive data is the default of 60 seconds
Memory_limit = 256m; max memory consumed per PHP page, default 8M
After modifying the above parameters, it is possible to upload large volume files under normal conditions allowed by the network.


Detail code: upload.html

 
  upload.php
 
   0)    {    echo "Return Code:". $_files["File" ["Error"]. "
"; } else { echo "Upload:". $_files["File" ["Name"]. "
"; echo "Type:". $_files["File" ["type"]. "
"; echo "Size:". ($_files["File" ["Size"]/1024). The Kb
"; echo "Temp file:". $_files["File" ["Tmp_name"]. "
"; if (file_exists ("/tmp/cyupload/". $_files["File" ["Name"])) { echo $_files["file" ["Name"]. "already exists."; } else { move_uploaded_file ($_files["file"] ["Tmp_name"], "/tmp/cyupload/". $_files["File" ["Name"] ); echo "Stored in:". " /tmp/cyupload/". $_files["File" ["Name"];}} } else { echo "Invalid file"; }? >

?

  • 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.