A little background. I am using plupload to upload files within my application.
The url
passed is the url to my aspx where I handle all the processing of the file.
What happens is, the first time you browse for and select a file nothing happens. The second time, it posts back both form submissions immediately.
Can you find any glaring omissions from the below code?
// Initialize the uploader
uploader = new plupload.Uploader({
runtimes: 'html5,gears,flash,silverlight,browserplus',
browse_button: 'browse',
drop_element: 'uploadContainer',
container: 'uploadContainer',
max_file_size: '10mb',
multi_selection: false,
url: 'someURLHere',
filters: [{ title: "Pdf files", extensions: "pdf"}]
});
FilesAdded event fires when (obviously) a file is added
// File Added event
uploader.bind('FilesAdded', function (up, files) {
$.each(files, function (i, file) {
// Add element to file object
file.formattedSize = plupload.formatSize(file.size);
$('form').submit();
// Reposition Flash/Silverlight
up.refresh();
});
Submit the form
$('form').submit(function (e) {
uploader.start();
e.preventDefault();
});
HTML
<form id="uploadForm">
<div id="uploadContainer">
<span id="uploadDragText" style="display: none;">Drag and Drop items here</span
<div id="fileList"></div>
<button id="browse" class="ButtonSubmit">Browse...</button>
</div>
</form>
I was using this great answer as a starting point. using Plupload with ASP.NET/C#