i have an laravel application. There is a big form in my app and there are input and file fields in it. I use DropzoneJs for file uploads. First , user fills inputs and puts files into dropzoneJs area. Than user clicks submit button and all inputs and files goes to server. But there is a problem with this solution. If user uploads big files to server , it takes too much to time. And user waits too much at the end.
How can i prevent this ? With dropzoneJs i can send files when i select without submit the form. But what will i do if user give up to fill form ? I can't create a new field in database because of this.
Is it possible to send files to a temporary place or layer before submit the form. when user select the files , it upload files to this layer. if user submits the form , files goes to server folder and i can persist it to database.
I solve the issue with creating a tmp folder
. First , i send files to tmp folder
than if user submits i use php's rename
function to move files to my uploads folder
. Than i persist the data to database.
If form fails , it's not problem. Because i setup a daily cron
to clean my tmp folder.