oabraham's avatar

Which is best when uploading Files

Hey everyone, I just need to sample expert opinions as am building an application that requires user to upload large files (max. 50MB). Which is better, either to upload the file directly to the server when the form is submitted or i asynchronously upload the file through Ajax to the server, wait for success response and then submit the form. Am uploading the file straight to AWS S3.

Your opinions are greatly appreciated. Thank you!

0 likes
7 replies
deadlockgB's avatar
Level 3

Actually this is more the question of presentation to the user. When you use AJAX and for simplification a upload library that does some percentage processing etc. for you, you should go with AJAX since the user is not only seeing a loading symbol in the tab of his browser but can be guided by a status box/modal or something or a percentage element/progressbar.

1 like
bashy's avatar

Make sure execution time is for input data is set high... on slow upload speeds, this could still be reached if it takes longer than the max time.

max_input_time
1 like
fideloper's avatar

I'd attempt to go straight to amazon in an attempt to get around issues that can occur when uploading large files to PHP, which include:

  • Using a lot of memory (the amount of the file + normal amount needed for processing the request

And within php.ini:

  • limits on max_input_time
  • limits on max_execution_time
  • limits on post_max_size
  • limits on memory_limit (must be at least as large as your largest file+extra needed to process the request, and go larger if you can!!)
  • limits on upload_max_filesize
2 likes
oabraham's avatar

@fideloper Yes, I am uploading directly from upload tmp folder straight to S3. Would go the AJAX way and also take note of setting the max_input_time in php.ini as @bashy recommended.

Thanks guys, always a pleasure :)

bashy's avatar

@fideloper Unless the POST action is directly to another server (AWS), it will still require those settings for the initial upload to the website site server?

Please or to participate in this conversation.