Home > Backend Development > PHP Tutorial > Using discuz to implement PHP large file upload application example code

Using discuz to implement PHP large file upload application example code

WBOY
Release: 2016-07-29 08:39:12
Original
1379 people have browsed it

For those who really need to improve the conditions for uploading forum attachments, you can try to set the parameters mentioned above in php.ini to adapt to the needs of large file uploads. At the same time, don’t forget to set the attachment restrictions in the background of the forum.

There are two main places in the forum where you can limit the size of attachment uploads. The levels from high to low are:

  • Post related---Attachment type size
  • User Group---Attachments related

At the same time, here is a configuration guide provided by some friends who have successfully uploaded large attachments through http. Of course, due to different server configurations and network conditions, it may not apply to you. In this case, many places may need to be modified by reference:

Open php.ini,

Parameters Settings Description
file_uploads on Switch whether to allow file uploading through HTTP. The default is ON, that is, open
upload_tmp_dir -- The file is uploaded to the place where temporary files are stored on the server. If not specified, the system default temporary folder will be used
upload_max_filesize 8m Wangwen business, that is, the maximum size of the file allowed to be uploaded. The default is 2M
post_max_size 8m refers to the maximum value that can be received through form POST to PHP, including all values ​​in the form. The default is 8M
Explanation
Generally, after setting the above four parameters, when the network is normal, uploading files of
But if you want to upload> For a large file of 8M, it will definitely work if you only set the above four items. Unless your network really has a 100M/S upload speed, you have to continue setting the following parameters.
max_execution_time 600 Maximum time value (seconds) for each PHP page to run, default 30 seconds
max_input_time 600 Maximum time required for each PHP page to receive data, default 60 Seconds
memory_limit 8m The maximum memory consumed by each PHP page, default 8M

After modifying the above parameters, you can upload large files under normal circumstances allowed by the network

Common error types in forum file uploads (continuous summary...)
  • Warning: Unable to open '\php2' for reading: Invalid argument in e:userweblarksoft.netuploadupfile.php on line 10

is for php The reason for upload_tmp_dir, the specified directory must be readable and writable

  • Parse error: parse error in c:program filesapache groupapachehtdocsmdwebftpfileupload.php on line 14

Parse error is generally a statement problem, such as ";", Matching problems with "'", ")", etc.

The above has introduced the example code of using discuz to implement PHP large file upload application, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template