Ajax Drupal detect uploaded image too large - php

I'm trying to solve a problem on a content (agenda) creation form which needs two images uploaded by the admin. The problem is when we create the content for the first time and try to upload the images, we got in the console a Drupal Ajax error which prevents the form to be correctly submitted.
The error:
When I visit the page that contains the debugging information it says that the uploaded file exceed the maximum file size allowed by the server (40 MB) although I uploaded a 100 KB image.
In the content type of my agenda, both my images fields have the 40 MB limit set up and same for my php.ini upload_max_filesize is set to 40 MB
I have confirmed that this error can be reproduced on different environments (Windows + Xampp and Linux + Nginx)
I ran out of ideas, so if everyone has any ideas on how to fix this, I would appreciate ^^.

In your Nginx server config try something like:
server {
client_max_body_size 40M;

Related

Can't Upload Image using WordPress Media Upload

I'm trying to upload an image to my WordPress site. The image is 5.6 MB big.
The resolution is 1920px x 1444px.
I've already uploaded a much smaller image (0.5MB / 939px x 471px). That worked fine.
I'm getting this error message: The server cannot process the image. This can happen if the server is busy or does not have enough resources to complete the task. Uploading a smaller image may help. Suggested maximum size is 2560 pixels.
WHAT I HAVE TRIED:
I have already tried a few things:
Changed the upload_max_filesize, post_max_size, max_execution_time in the php.ini File
(WordPress even says that the max size is 128M now)
Changed the 'big_image_size_threshold'
Uploaded the images to the Server via SFTP, renamed them according to the Other images that are in the Folder, but that didnt work as well
Installed a few plug-ins that change the max upload size. Didnt work either.
I've looked at so many websites, but they all gave me these as solutions.
Has anybody got any Idea? Thank you in advance.
WHAT I AM USING:
Operating System: Debian GNU/Linux 10 (buster)
PHP-Version: 8.0
WordPress Version: 6.1.1
Also I'm using Nginx not Apache2
Dean
1- try deactivating all other plugins temporarily , it may happen sometimes due to some plugin process the images before uploading to the server.
2- if you want to upload any file to the wordpress outside the wordpress dashboard make sure to use the plugin named " Add From Server " , for this case you first upload your file to the directory then u import them via this plugin to your wordpress database so it loads in the wordpress dashboard.
3- at last if you using any control panel to manage your server , check the php.ini setting in its control panel , sometimes setting in the server overwrite the local php.ini in your website directory.

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?

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?

File upload in PHP not returning error code

I have a problem when attempting to upload really big files using PHP. I know this has been raised before and I have read many responses, but I have not found a definitive answer.
The basic code I use is posted here: http://design.wildsandwebdesign.co.uk/technical/uploading-files-2.php and I have used this with complete success for letting client upload image files, JPEG, GIF, png etc. The problem arose in allowing users to upload non-displayable files such as .psd files which can be very large.
In php.ini on both my local and remote servers upload_max_filesize and post_max_size are set to 128MB. The hidden field MAX_FILE_SIZE in the code has been set to various values during development. The problem is this: If the user selects a file bigger than the MAX_FILE_SIZE but smaller than 128MB,$_FILES['uploadfile']['error'] returns an error code of 2 as the PHP documentation says it will. If the file size exceeds 128MB then the upload handling fails altogether with bizarre results.
The “bizarre” results include irrelevant error messages such as “Undefined index: uploadbtn” this being the index of the submit button you have to click to get the error message(!) This happens with Firefox 26 and with Chrome. Bigger files can crash Firefox altogether which then displays the bug report dialog.
I don't want to upload files larger than 128MB, I just want to handle the situation where a user selects a very large file in some reasonable way. Does anyone know how to do this?
The production code is very much more complicated than the example above but I will happily provide it on request.
......

Categories