Use discuz to implement PHP large file upload application instance code _ PHP Tutorial

Source: Internet
Author: User
Use discuz to implement PHP large file upload application instance code. If you really need to improve the uploading conditions of Forum attachments, you can try to set the parameters mentioned above in php. ini to meet the needs of uploading large files. At the same time, do not forget that after the forum, you can try to set the above parameters in php. ini to meet the needs of uploading large files. At the same time, do not forget to set attachments in the background of the Forum.

There are two main parts of the Forum to limit the size of attachment uploads, from high to low:

  • Post-related --- attachment type size
  • User group --- attachment related

At the same time, the following provides configuration guidance from friends who have successfully uploaded large attachments via http. of course, due to the different server configurations and network conditions, this does not necessarily apply to your situation. you may need to modify it in many places:

Open php. ini,


Parameters Set Description
File_uploads On Whether to allow file upload over HTTP. ON is enabled by default.
Upload_tmp_dir -- The file is uploaded to the place where the temporary file is stored on the server. if it is not specified, the default temporary folder will be used.
Upload_max_filesize 8 m Wangwen business, that is, the maximum file size allowed to be uploaded. The default value is 2 MB.
Post_max_size 8 m The maximum value that can be received by posting a form to PHP, including all values in the form. The default value is 8 MB.
Description
Generally, after the preceding four parameters are set, uploading a file <= 8 m is not a problem under normal network conditions.
However, if you want to upload a large file larger than 8 MB, you can only set the above four items. Unless your network has a high upload speed of 100 MB/s, you must set the following parameters.
Max_execution_time 600 Maximum time (in seconds) for running each PHP page. the default value is 30 seconds.
Max_input_time 600 Maximum time required for receiving data on each PHP page. the default value is 60 seconds.
Memory_limit 8 m Maximum memory consumed by each PHP page. the default value is 8 MB.


After modifying the preceding parameters, you can upload a large volume of files as permitted by the network.

Common error types for uploading Forum files (continuous summary ...)
  • Warning: Unable to open '\ php2' for reading: Invalid argument in e: \ user \ web \ larksoft.net \ upload \ upfile. php on line 10

Is the reason for php's upload_tmp_dir. the specified directory must be readable and writable.

  • Parse error: parse error in c: \ program files \ apache group \ apache \ htdocs \ mdweb \ ftpfile \ upload. php on line 14

Parse errors are generally statements, such as ";", "", and.

Bytes. At the same time, do not forget the post of the forum...

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.