I'm lost here. I'm trying to set up a simple file upload, handled by SWFUpload. After file selection nothing happens. I don't see a request being sent, and there is nothing in my console. Is the swf object supposed to call my upload_url page immediately?
var swfu,jobForm;
var j = jQuery.noConflict();
j(window).load(function() {
jobForm = j('.admin-atomic-form form');
swfu = new SWFUpload({
upload_url : "URL/upload.php",
flash_url : "URL/swfupload.swf",
file_size_limit : "20 MB",
file_types : "*.doc;*.pdf;*.rtf;*docx;*.jpg;",
//file_types_description : "All Files",
file_upload_limit : "1",
button_placeholder_id : "swfuploader",
button_image_url : "URL/file-browse.png",
button_width: 100,
button_height: 30,
upload_start_handler : uploadStart,
upload_success_handler : uploadSuccess
});
//jobForm.form.submit(function(ev){ev.preventDefault()})
});
function uploadStart(){
//.submit()
console.log(this,'start');
};
function uploadSuccess(){
//form.submit()
console.log('success');
}
SWFUploadObj.startUpload();
needs to be fired and that's what initiated the POST request to the specified upload_url. If this method is fired by some default setting, it certainly wasn't doing it for me.
Here is an example of a few of my functions:
// Bound to file_queued_handler : sets a flag that there is a file waiting to upload
function swfuFileQueued(file){
resumeQueued = true;
$j('#browseFile').val(file.name);
}
//Bound to form submit event:
//a successful upload will submit this form again once the success response with the server-moved and renamed filename comes back from the file upload handling script
function swfuFormSubmit(ev){
if(uploadSuccess){
return true;
} else {
if(resumeQueued == true){
ev.preventDefault();
swfuUploadStart(); // see next function
} else {
return true;
}
}
}
function swfuUploadStart(){
try {
swfu.startUpload(); // <-- The actual method that begins the file upload request
} catch (e) {
}
return false;
}
function swfuProgress(){ ...
function swfuError(){ ...
function swfuSuccess(){
//update input element containing filename or id to send with form
//update a status box with "Success"
//uploadSuccess = true
//form.submit() once more, this time uploadSuccess will tell the function to continue on and actually submit itself
Useful URL to understand SWFUpload process : http://www.dconstructing.com/2010/07/08/making-swfupload-work