Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>All of the above is possible with the blueimp file upload plugin.</p> <p>1) Decide if files get uploaded or not</p> <p>Use the <code>add:</code> option in the plugin to make a separate ajax call to the server with the filenames added, and use the response to filter the list of files to be uploaded.</p> <p>2) Add other data from the form to the upload</p> <p>Use the <code>formData:</code> option in the plugin to add the other fields in a form to be passed to the server upon submit.</p> <p>So something like the following:</p> <pre><code>$('#fileupload').fileupload({ url: url, dataType: 'json', autoUpload: false, acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, maxFileSize: 5000000, // 5 MB loadImageMaxFileSize: 15000000, // 15MB formData: $("#myForm").serializeArray() }).on('fileuploadadd', function (e, data) { data.context = $('&lt;div/&gt;').appendTo('#files'); $.ajax( url: "/checkfiles", data: { files: data.files }, success: function(result) { // assume server passes back list of accepted files $.each(result.files, function (index, file) { var node = $('&lt;p/&gt;') .append($('&lt;span/&gt;').text(file.name)); if (!index) { node .append('&lt;br&gt;') .append(uploadButton.clone(true).data(data)); } node.appendTo(data.context); }); } }).on('fileuploadprocessalways', function (e, data) { var index = data.index, file = data.files[index], node = $(data.context.children()[index]); if (file.preview) { node .prepend('&lt;br&gt;') .prepend(file.preview); } if (file.error) { node .append('&lt;br&gt;') .append(file.error); } if (index + 1 === data.files.length) { data.context.find('button') .text('Upload') .prop('disabled', !!data.files.error); } }).on('fileuploaddone', function (e, data) { $.each(data.result.files, function (index, file) { var link = $('&lt;a&gt;') .attr('target', '_blank') .prop('href', file.url); $(data.context.children()[index]) .wrap(link); }); }).on('fileuploadfail', function (e, data) { $.each(data.result.files, function (index, file) { var error = $('&lt;span/&gt;').text(file.error); $(data.context.children()[index]) .append('&lt;br&gt;') .append(error); }); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload