Loading Images with PHP Script Failure

I'm new to PHP, but I'm having a recurring problem with several different scripts and servers when uploading images via ShareX to my server with a custom script, specifically this one .

I was migrating servers (I was on a shared host, now I'm on a VPS) and have since changed it to use a script, but I still have a problem and I don't know what the problem is.

The problem (not running for 100% of the time, but it does most of the time, sometimes it works after trying again) is that loading images at a specific size, roughly 250-500KB, or fail most of the time, After 60 seconds I getting 502 error (Bad Gateway) on ShareX.

I have looked at general solutions for similar problems ("large" files sync with PHP) and checked the following variables in my PHP.ini file.

max_execution_time = 60
max_input_time = 60
memory_limit = 128M
post_max_size = 8M

      

When the upload is successful, it only takes a few seconds to download and get the link to the uploaded image, but when that fails, it always takes 60 seconds and then an error. There is no intermediate point, it is deleted instantly, or it expires after 60 seconds.

I don't know exactly how to find what exactly is the error (if any). When this happens, ShareX reports an error (502) Bad Gateway, "Answer:" is just the source of the page (the script is configured to redirect to this page if it detects that you are not downloading anything or it fails), and " The stack trace "looks like this:

StackTrace:

at System.Net.HttpWebRequest.GetResponse()
   at ShareX.UploadersLib.Uploader.UploadData(Stream dataStream, String url,     String fileName, String fileFormName, Dictionary`2 arguments,     NameValueCollection headers, CookieCollection cookies, ResponseType responseType, HttpMethod method, String requestContentType, String metadata)

      

Edit: my server is behind a cloud flag and I read that a cloud device can cause problems. However, I checked the settings and the max upload size is set to 100MB on cloudflare and pausing it doesn't seem to help.

Edit: I removed the limit on post_max_size, which was 8M, and it seems to have partially fixed the problem. Now I can upload things up to about 3MB, but after that it always fails with a custom error message from the script.

+3


source to share


1 answer


When increasing the limits of the POST file, you may need to change at least 2 settings:

upload_max_filesize = 30M



post_max_size = 32M

Don't think this has anything to do with CloudFlare. See if you can check the error log for Apache if the above settings don't work.

0


source







All Articles