Discuz! When an image is uploaded, the system prompts "no valid file has been uploaded"

Source: Internet
Author: User
Tags file upload

A customer reported to us that the DZ Forum installed on our server could not upload images. After obtaining the administrator account provided by the customer, the Post test found that there was no problem in uploading images, therefore, we asked the customer to provide us with an incorrect image and the message "no valid file was uploaded" was displayed.

The size of the image is more than 800 KB, and the size of the online Upload prompt is limited to 2 MB, I searched the internet for a post that uploads a large image and prompts "there is no valid file to be uploaded". This error is caused when the image resolution is too high, so I looked at the image size provided by the customer, and the width reached more than 10000 pixels...

After scaling the image size by 10 times with PS, try uploading again. This problem is solved.

Solution 2

The solution is as follows:

Solution

Source/class/discuz/discuz_upload.php

Edit this file and set
Because the program limits the size (resolution) of the attachment image, the system prompts "no valid file is uploaded"
Change Method: sourceclassdiscuzclass_upload.php
Find:

The code is as follows:

Function get_image_info ($ target, $ allowswf = false ){
$ Ext = discuz_upload: fileext ($ target );
$ Isimage = discuz_upload: is_image_ext ($ ext );
If (! $ Isimage & ($ ext! = 'Swf '|! $ Allowswf )){
Return false;
} Elseif (! Is_readable ($ target )){
Return false;
} Elseif ($ imageinfo = @ getimagesize ($ target )){
List ($ width, $ height, $ type) =! Empty ($ imageinfo )? $ Imageinfo: array ('','','');
$ Size = $ width * $ height;
If ($ size> 16777216 | $ size <16 ){
Return false;
} Elseif ($ ext = 'swf '& $ type! = 4 & $ type! = 13 ){
Return false;
} Elseif ($ isimage &&! In_array ($ type, array (1, 2, 3, 6, 13 ))){
Return false;
                        }
Return $ imageinfo;
} Else {
Return false;
                }
        }


Find the file: sourceclassdiscuzclass_upload.php

Change 16777216 in if ($ size> 16777216 | $ size <16) to a greater value to solve the problem.

16777216 is about 5000*3356.

Error: Error 500

The solution is to edit the php. Ini file.
Set

Open php. ini, first find
;;;;;;;;;;;;;;;;
; File Uploads;
;;;;;;;;;;;;;;;;
Region, which has the following parameters that affect file upload:

File_uploads = on; whether to allow file upload over HTTP. ON is enabled by default.

Upload_tmp_dir; upload the file 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.

In
;;;;;;;;;;;;;;;;;
; Data Handling;
;;;;;;;;;;;;;;;;;
Region:

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.

Generally, after the preceding four parameters are set, uploading the file <= 8 m is not a problem, but the network is normal.

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 Mbit/S, you have to pay attention to the following parameters:

;;;;;;;;;;;;;;;;;;;
; Resource Limits;
;;;;;;;;;;;;;;;;;;;

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 M.
Memory_limit is set to be larger until the image can be uploaded smoothly.

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.