500 Internal Server Error When Uploading Images Using PHP - php

I'm offering users the ability to upload files using an online form, but I keep on getting 500 internal server errors whenever the file upload is processed. This is what I know:
The problem isn't related to php.ini. I've checked the max file upload size, and it's set at 2 megabytes. I get the same 500 internal server error uploading 3kb large files, as well as 100kb large files.
The problem isn't related to file permissions. The php file I'm using to upload, upload.php, has permissions set to 664, and the upload folder, called upload_pic, has folder permissions of 755.
This is not an issue with the code. The exact same code was working on my previous server. I recently bought a new server and am migrating the sites over, and this is where I'm getting my problem.
I've looked online for the past two days, but I just can't find what's causing the problem. I've seen many issues similar to mine, but most of these were resolved by changing file/directory permissions, or making edits to php.ini.
Does anyone have any other proposed solutions?
Thanks!

Related

Error when uploading files larger than 500MB on vps server

I have a vps server (on hostinger) running on openlitespeed (cyberpanel). The website that I built uses PHP.
I created a file upload service and set my php config's post max limit to 1024M and upload max filesize to 1024M as well since both those settings work on my local when testing for large file uploads under 1gb. (I've also restarted php, as well as my server to see if it solved the issue but it still persists. I've also created a phpinfo file to confirm if my post max limit and upload max filesize were changed to 1024M/1G and they were changed)
But on my webserver, uploading files larger than 500mb gives me a "POST net::ERR_HTTP2_PROTOCOL_ERROR" on my console pointing to a line on one of my javascript code referring to my xhttp.send (specifically xhttp.send(formData) XML Http Request. This XML http request forwards the selected file to an upload.php script that processes the data. But it's not getting sent to that script due to the error.
When I get that error when uploading files larger than 500mb, I'd also get an error in my server's error log:
[NOTICE] [xxxx] [T0] [xx.xxx.xx.xxx:xxxxx:HTTP2-3#APVH_*:443_website.com] Request body size: <filesize> is too big!
The uploader works fine when uploading files under 500mb, it sends the formdata to the php upload script and stores it in the server as well as the database. But it gives an error when uploading more than that.
I've looked everywhere to solve this issue, I've also looked into openlitespeed's max request body size since it's seems like it's what the error on my error log shows, but most of the answers I've seen were from several years ago and no longer applies and didn't resolve the issue.
There doesn't seem to be any issue with my php script as well as my javascript from my tests since it works with no issues on my local server, and works fine with small file sizes on my web server.
Is there anyway to resolve this issue?

Cannot Upload .GLB to Wordpress Media Location

This is not a quick failure, I have spent a totally of 5 completely full days trying to figure this out. Initially I was limited by file size and then file type; in which I removed the Wordpress restrictions and am now "capable" of uploading my 177MB .glb file to Wordpress.
However when doing so, I receive the following error:
retriever.glb
Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.
I was on the phone with GoDaddy Specialists for 2.5 hours yesterday ensuring that this was not a Server issue or restriction on their side.. they confirmed that it was not. We pretty much ended the conversation that it is something I must figure out with me, myself, and I.
I went ahead and uploaded my .glb to the server through panel, everything worked fine. In fact I have a location for it here: https://www.tattiniboots.com/wp-content/uploads/2020/07/retriever.glb
However, this does not make the file discoverable to the 3D viewer plugins I have installed on the site through the media location.
I truly don't know where to go from here
I changed the name of the file to .png and attempted an upload and received the following error:
Post-processing of the image failed likely because the server is busy or does not have enough resources. Uploading a smaller image may help. Suggested maximum size is 2500 pixels.
I just tried to update a normal .mov file that is 150MB and received the following error; really making me think this is something to do with file size:
Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.
Yes, normal images are uploading just fine (2MB-ish)
I just attempted to deactivate all plugins with consideration that maybe "Smush" or another was imposing issues: I then received the issue that the file type is not supported (even with the allow all file types code in my wp-config)
Is this just the case that glb is not allowed at all?
This must be a server thing. probably a run time error
Whoever supported you just doesn't know it. GoGoDaddy. ;)
Nevertheless... you can Use a plugin that's called
media sync. Check it out and best of luck

Laravel - Uploading multiple images for a single request doesn't work well on shared host

I am uploading more than 12 images files for a single requests but the online server refuses to upload those images. In my local machine it works fine, i can upload more than 20 images at once. I have configured the PHP settings for max_file_uploads = 60, upload_max_filesize=100M, post_max_size = 125M in php.ini, both on my local machine server and online server. While sending the page loads unfinishing, and at the end after a long time it responds with a Network Protocol Error, which says that:
"An error occurred during a connection to www.mydomain.com. The page you are trying to view cannot be shown because an error in the network protocol was detected."
See the screen shots of other different error responses i've also got after many trials, and it still takes a long time of loading to get those responses after sending.
The images that i am uploading are being saved on server but not all. When i upload 20 images for a single request, it can get only 8 or 10 and sometimes the last image is cut short(interrupted) before it is fully uploaded, see its picture below.
I need to get all the images i am uploading like in my local machine, and with a quick response. What else i can do for configuration in PHP or elsewhere? What's wrong on shared hosting server? Please, if you have any answer to this, you can tell me what i can do, to get all uploaded images files with a quick response.
It's clearly because of a timeout error. It's not acceptable to send multiple files with one request. Even if you get it to work right now, it will fail from time to time depending on the user connection speed and file size. Also you mentioned a quick response. So you definitely need to use ajax upload to upload files simultaneously. There are multiple upload libraries such as dropzone.

File upload timeout Laravel 5.6

I am using the
Storage::
to upload files into laravel. It works, i can successfully upload, store, delete, and edit files on the server. But the issue i am having is the weight of the file. Images upload easily, but if i try to upload a .zip with like 20MB it drops. I can see the numbers in the bottom of the browser going all the way to 23 then back to 0, up to like 10% then this pages comes up:
What is going on? I updated my PHP.INI to allow really large uploads... is Laravel got some restrictions? Does Nginx have its own set of permissions? What am i missing?

FTP upload through a PHP page

I have an administration page on a website, from which the admin AND THE ADMIN ONLY can manage users and upload files from local hard drive for these users to download. The admin uses this page to upload files for his customers or to store files he needs when he has no memory device available. The files size may vary from a few Kb to a lot of hundreds megabytes.
The ideal solution:
An HTML form through which the admin can choose a file and upload it, to download it back later. This can be done in PHP.
The problems:
I cannot set the "max_file_size" variable in php.ini because the hosting doesn't let me
I tried FTP upload (PHP function ftp_put()) but it requires me to upload the file with a POST anyway
Even though it's completely wrong, I used a input="text" instead of input="file" to write the whole file path and upload it, but I get the following error:
Warning: ftp_put(insert_local_file_path_here)[function.ftp-put]:
failed to open stream: No such file or directory in path_to_php_script.php on line 70
The insane thing is... on Monday this was working, and now it's not. No changes were done and the file is the same.
My only conclusion:
With my little knowledge, all I could think of is a Java applet which does the required tasks that opens on the administration page. But if someone disables javascript/has no Java installed, the thing will not work, so it's not 100% bulletproof.
Have you got any ideas how to overcome such an issue?
If you need to upload big files you must use ftp protocol to make it. You can't upload big files if you don't have acces to php.ini. Sad but true

Categories