kasijus's avatar

Dropzone file uploads

I am building a create form for a typical resource. It's a huge form, lots of fields with the possibility to upload some photos, like logos, cover photo, etc...All in one form. I need the drag&drop option for the photos, and I wanted to use the Dropzone plugin.

Now, Dropzone uploads files instantly. I am not sure how to handle those files uploads if I don't have the resource created yet. How should I connect those files to the resource later, when the original 'create' form is submitted?

I thought I might FIRST create the resource and then show a 'create' view, and pass the new ID to the view. Then, I could attach that ID to each file upload and connect the file to the resource. Would this be right way to do it?

Or is there any other, better way?

0 likes
6 replies
jlrdw's avatar

I didn't think it was instant, can't you program event listeners to actually upload on a click event?

kasijus's avatar

When you choose/drag&drop a file, using Dropzone, it immediately sends an AJAX request to the defined route.

If you are talking about JS event listeners, that doesn't change anything, the files still go to the backend before the main form is submitted.

kasijus's avatar

That looks good, but it's still AJAX request. So, I guess there's no 'more Laravel friendly' way to do that, with regular form submission.

jlrdw's avatar

The title stated

  • Combine normal form with Dropzone

Please or to participate in this conversation.