big size multi image upload - php

I built a website in that I upload 10 too big size(10MB) images. When uploading start, it continues to some time then a blank page will come. I tried to change php_values in .htaccess file, because I don't have permission to change the settings in php.ini file (it's shared server). I have some doubts regarding this.
1) what happen if file will going to post request, because I want fastly uploded the files.
2) it takes time when posting the request or uploding the file, I am cropping the images (loop) using php GD functions.

It is because of the limits your web hosting provider set. Which values did you try to change in the .htaccess?
You could try using some flash uploader, it should work despite the limits imposed by the server. A good one is SWFUpload.

That is because of the exection time of a script.You can edit your php.ini file. If that is not permitted you can set the *MAX_EXECUTION_TIME* for a script using your .htaccess file.

Related

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?

How can I get the IIS upload limit using PHP?

I want make a check against the IIS upload limit of the server my PHP script is running in the same manner as ini_get('upload_max_filesize') works for the PHP settings.
I'm thinking about parsing the web.config file to get the value of maxAllowedContentLength, but I was wondering if there is a standard way to ask the webserver directly.
There is one link telling a bit about other configuration setting you should read Which gets priority, maxRequestLength or maxAllowedContentLength? And i dont think there is other way as to read the ini file (php have simple ini file reader).
I could propose using some library that splits files like plupload - it can split your files to smaller pieces, upload each piece and then recombine it into one big file bypassing the server maximum upload file / body limits.

PHP Uploading Multiple files always gives me timeout error

Ok, I don't quite understand why, but no matter what I seem to set in PHP's ini_set function, I am unable to upload multiple files or the files that I'm uploading are too big... I don't understand it. Here's what I am setting so far within the script that handles the $_FILES[] array that is being uploaded when posting the form:
// Try and allow for 3 hours, just in case...
#set_time_limit(10800);
// Try and set some ini settings to buy us some time...
#ini_set('memory_limit', '512M');
#ini_set('upload_max_filesize', '512M');
#ini_set('post_max_size', '550M');
#ini_set('session.gc_maxlifetime', '10800'); // Allows for up to 3 hours
#ini_set('max_input_time', '10800'); // Allows for up to 3 hours
#ini_set('max_execution_time', '10800'); // Allows for up to 3 hours
I am using move_uploaded_file to place it into the specified directory, not sure if that matters or not?
Honestly, how can I allow multiple files to be uploaded without a TIMED OUT ERROR?? If I upload 1 file, seems fine. Not sure if it's a quantity problem with multiple files or the combined files are just too big in filesize? Have tried with like 15MB total filesize, and this produces a TIMED OUT ERROR! arggggg!!!!
What must I do to make this work??
If you are using an apache server, the server itselfs has a timelimit too.
Look at the TimeOut directive at apache configuration (by default is 300 seconds)
You can look at the apache error log too
If you upload only 2 files ok 1Kb each, works fine?
For uploading large + multiple files reliably you should use file uploaders
I prefere http://www.uploadify.com/ for this

PHP file uploads being "hijacked" by partial uploads

I have a site that is receiving 30-40k photo uploads a day and I've been seeing an issue pop up with more frequency now. This issue is this:
Our upload script receives (via $_FILES['name']['tmp_name']) a file (photo) that was NOT uploaded by the user & the majority of the time the file received is a "partial" upload.
Of course at first I thought it was my PHP code making a simple mistake and I've spent days looking over it to make sure, but after placing checks in the code I've found that the file received via a HTTP POST upload to PHP is actually the wrong file. So the issue is happening before it reaches my code. The tmp file (phpxxxx) received by the script is sometimes incorrect, as if it was somehow being overwritten by another process and its usually overwritten by a file that was partially uploaded.
Has anyone every seen an issue like this? Any help is greatly appreciated. I'm turning to this as a last resort after days of searching/asking other PHP devs
So to recap:
User uploads a photo
PHP script receives a file that was not uploaded by the user (pre code, via $_FILES in /var/tmp)
Usually the incorrect file received is a partial upload or a broken upload
It seems to happen randomly and not all the time
First off, check you PHP version.
Second, check your file upload limits and POST_MAX_SIZE in php.ini
It might just be that someone tries to upload a file that's too large :-)
Can you try different names for the temp file to avoid its being overwritten? Can you identify the origin of the new, incorrect and incomplete file?
Is this a development environment? Is it possible that more than one user is uploading files at the same time?
Try your program with very small images to check if SchizoDuckie is correct about filesize problems.
Try with different navigators to eliminate the admittedly remote possibility that it is a local problem.
Check permissions on the directory where the temp file is stored.
PHP's built-in file handling does not support partial uploads.
Turn off KeepAlives and/or send a 'Connection: close' header after each upload.
Configure your webserver to send the header 'Allow-Ranges: none'.

Categories