This is a set of tests, to confirm that AJAX Upload works with most options.
Inline "A" element as upload button
When alerted upload is disabled. Select Submit & Enable
Check with image and some other file
var upload = new AjaxUpload(jQuery('#test4'), { action: 'upload-test.php', name: 'woohoo-custom-name', data: { 'key1': "This data won't be sent, we will overwrite it." }, autoSubmit: false, responseType: 'json', onChange: function(file, ext){ }, onSubmit: function(file, ext){ // Allow only images. You should add security check on the server-side. if (ext && /^(jpg|png|jpeg|gif)$/i.test(ext)) { this.setData({ 'key1': 'This should be alerted', 'key2': '...' }); } else { alert('not image'); return false; } }, onComplete: function(file, response){ this.disable(); alert(response.post.key1); } }); jQuery('#test4upload').click(function(){ upload.submit(); upload.enable(); return false; });
new AjaxUpload(document.getElementById('test5'),{ onChange: function(file, ext){ return false; } });