12

I really love the client side processing of selecting a file and having a preview with the option to cancel or delete.

However i want to upload the page with a form and i don't need to use ajax. I have been fiddling with all the options and i cant find anyway to post to form with the files selected synchronously.

Is it possible to get data.files to post with the form?

9
  • A file upload without AJAX is pretty simple in most languages. It seems that your question is not quite clear. whathaveyoutried.com Commented Feb 15, 2013 at 13:57
  • 1
    Jay Blanchard have you used the blueimp jQuery-File-Upload? I understand that's its very simple to do a file upload without ajax, that wasn't my question. My question was using blueimp jQuery-File-Upload to do a synchronous form post. Commented Feb 16, 2013 at 5:07
  • 1
    Posting files with a form requires an upload component to go along with the form posting component, but I am unsure what you mean bt "synchronous" in this context? Do you meaning posting the form data and uploading something at the same time? If so see this - github.com/blueimp/jQuery-File-Upload/wiki/… Commented Feb 18, 2013 at 20:57
  • 3
    @JayBlanchard He meant submitting the form normally (without ajax). The Jquery-File-Upload would only be used as the GUI. So a user can add files, remove files, drop files, etc. When he is all done, and has filled out the rest of the form, he hits submit and the entire form is submitted and processed on the backend as it would have been processed without the JQuery-File-Upload. Any ideas? Commented Mar 29, 2018 at 13:49
  • 1
    @JayBlanchard Yes, my question is, how can you do what I'm describing... I'm not explaining myself well because the question isn't broad. Re "It doesn't make much sense to upload the file with AJAX...": The file is not being uploaded via AJAX, it is being uploaded with all the other information in the form. The question is how to use only the GUI that Jquery-File-Upload provides. Or, conversely, a straightforward way to code this funcitonality (add, remove, drop files). Commented Mar 29, 2018 at 14:28

2 Answers 2

10

You can submit files through a standard form submit using the blueimp jQuery-File-Upload by setting the replaceFileInput option to false.

From the documentation:

By default, the file input field is replaced with a clone after each input field change event. This is required for iframe transport queues and allows change events to be fired for the same file selection, but can be disabled by setting this option to false

Sign up to request clarification or add additional context in comments.

1 Comment

How can we change this option dynamically? I have an autosave(via ajax) form which user can disable and so he should be able to submit form normally. Right now when autosave is off and user submit form, selected file data are not passing to server.
-1
Use config replaceFileInput = false;
jQuery('#add_new_product_form').fileupload({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
            fileInput: jQuery('#upload-video'),
            replaceFileInput: false,
            ......
})

And controller you will get $_FILES to get video data.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.