Handle large photo upload - php

i would like to allow users to upload photos of any size to the server quickly. after which, my program will resize the original image to thumnail, scaled and probably a max width of 1020px. because of bandwidth issues (im on shared server currently), i would need to find a way to avoid loading for too long or reaches the max upload time limit.
i understand i can do these:
1. extend the max upload time
2. set max file upload size (which im trying not to)
please advise =)

There is no secret. The upload time depends on the users's bandwith. If he has a small bandwith the upload will take time and he maybe can reach the limit of your server.
There is no optimisation for that on your side. Moreover a shared hosting has a lot of bandwith available (several Gb) so it's probably impossible for your user to reach that limit even more in upload
Same thing with the memory limit. If you have a 8mb memory limit , trying to work on a 18MP photo will reach this limit.
Nevertheless you can seperate the two action :
1- Upload the photo
2- Redirect with header() when upload is done
3- Resize image or put it in queue for a later processing

Related

How to remote upload large files without setting time/memory limit and show progress info in PHP?

How could I use PHP to remote upload remote/third-party large files (1GB+) to my server (where server provider disabled modifying memory limit and time limit setting) with showing uploading process status (refreshing every 1s) to tell progress (how much of the file has been uploaded till now), transfer rate (current uploading speed), and time left (estimated time to complete the uploading process)?
I'm trying to remote upload remote/third-party files to my server. For example, let's say I've a link for a large file that I want to have a copy of on my server http://website.com/path/to/file.ext. What I'm looking for is a process to remote upload this file to my server with showing progress, knowing that I'm not allowed to modify either the memory limit nor the time limit settings.

Upload load big size file in PHP

I need to upload big size file by web page in PHP, as I surveyed, there are three variables related to upload.
post_max_size=100MB
upload_max_filesize=100MB
memory_limit
If I want to upload file under 100 MB, is that right just set size to 100 MB? and how much should I give to memory_limit for 100 MB file; Is there any other issue may cause the file can't finished upload.
The memory limit will be difficult because it depends on how you wish to process the file. If you're just going to write it to the disk without much processing, 100MB should be fine. If you're going to do any extensive processing on it, you may very well need to increase it higher depending on how your algorithm is handling memory usage.

Concurrent AJAX file upload LIMIT

I'm doing multiple file uploader to upload my files by using XMLHttp 2. When i'm doing this, if i upload the files one by one (by sending a file through an ajax request and waiting it to complete before sending the next and so on), the uploader works well. But when i upload multiple files by using concurrent ajax requests to upload multiple files concurrently, the browser hangs down. Here is the performance comparison,
So is there any maximum limit for UPLOAD FILE SIZE or NUMBER OF AJAX REQUESTS that the browser can handle concurrently?
Note: That red numbers shows the total upload time in that the Firefox(using firebug) consumes to upload all the files. In parallel upload, since all uploads happening concurrently, i took the time consumed by the largest file which ended at last.
There's no theoretical maximum for the number of concurrent uploads (unless the browser builders put one in explicitly).
However, in practice, upload speed performance drops significantly after two or three concurrent uploads due to bandwidth choking, with the exception of very low latency whereby the tcp window limits the maximum speed of a single upload.
I would recommend setting a concurrency limit of 2, especially if you're providing this to external users whose bandwidth may vary. Alternatively, you could do speed benchmarking as well, adapting the concurrency level based on measured upload performance.

Increasing the max concurrent file uploads on a LAMP server

I have an issue where my client wants to be able to upload more than 2 large files at a time, and i was wondering if any of you have a solution to this, i'm pretty sure that it is a setting in either Apache or PHP.
Here is what the scenario, i have an upload form for videos with a max file size of 1024MB (1GB), so when a user uploads 1 file that is less than or equal to 1GB it works fine, then they open a new tab and upload another large file, but when they open up a 3rd tab of that form and try to Upload i Get a IO error from the form, so i assume either PHP or apache is limiting the max number of concurrent uploads to the server.
Edit:
When i use another computer with a totally separate internet connection (separate/different external IP) i can upload there as well, so it seems like a max concurrent upload per client/IP.
I think increasing the memory assigned to a php script can help you, I don't think this is the most appropriate solution but when i was having problem handling lot of big files, I increased the memory for the script. If you are developing this for a very busy site i don't recommend this method but as far as i know try increasing the memory.
ini_set('memory_limit','128M');
for testing if you have -1
instead of 128M the system will give unlimited memory to the script. You can use this to test if the problem is caused due to memory.

PHP File uploading stops

For a client I have build a simple script that uploads multiple files(images), resizes them, stores them on a temporary folder and then later on move them to their destination.
Resizing is done using PHP's GD, as Imagick is not available.
These images are about 2/4 MB a piece and the client uploads about 30 images in one shot.
I used HTML5's multiple="" attribute which all works fine.
In tests all worked fine because I used Windows standard wallpaper images.
I can't find the source of the problem.
When uploading more then 1 image, the script failes debugging tells me it does upload the second image but won't resize.
I checked the memory usage for the images which is aprox 105724352 bytes each.
My PHP ini settings:
max_execution_time = 300
max_input_time = 600
memory_limit = 200M
So you see at the second image the memory reached it limit, making my script stop. Is that correct?
If so, how wise is it to upgrade the memory limit?
Thanks in advance!
EDIT:
It now seems the GD Function imagecreatefromjpeg cant handle files with a resolution bigger then 3500px wide, my files are bigger then 5000px wide.
Does anyone have a work arround for this?
At this point I am wondering if it is wise to have the client on a shared host at all if he needs so much memory for these images.
So you see at the second image the memory reached it limit, making my
script stop. Is that correct?
Check your Apache error logs under (**nix system) /var/log/apache2/error.log to see if it is really the problem.
If so, how wise is it to upgrade the memory limit?
You should not hande multiple image operations in one script. Make ajax queries for each, handle them in seperate instances.

Categories