I'm trying to use the provided examples but i can't get them to work. There is no error, but the swf button is not being loaded, why?
Here is my code:
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend settings
upload_url: \"".JURI::base()."components/com_newster/upload.php\",
file_post_name: \"resume_file\",
// Flash file settings
file_size_limit : \"10 MB\",
file_types : \"*.jpg;*png;*.gif\",
file_types_description : \"All Files\",
file_upload_limit : \"4\",
file_queue_limit : \"0\",
// Event handler settings
swfupload_loaded_handler : swfUploadLoaded,
file_dialog_start_handler: fileDialogStart,
file_queued_handler : fileQueued,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
//upload_start_handler : uploadStart,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete,
// Button Settings
button_image_url : \"".JURI::base()."components/com_newster/uploader/button.png\",
button_placeholder_id : \"spanButtonPlaceholder\",
button_width: 61,
button_height: 22,
// Flash Settings
flash_url : \"".JURI::base()."components/com_newster/uploader/swfupload.swf\",
custom_settings : {
progress_target : \"fsUploadProgress\",
upload_successful : false
},
// Debug settings
debug: true
});
};
also i've:
where can i start to look? I'm using firebug and there is no errors, and js scripts are being loaded...:S
regards
January 30, 2009 - 1:17pm
With "debug" set to true you should see a debug window. Are you getting output from that window?
January 30, 2009 - 9:37pm
Thanks gyphie, finnaly i've just found the problem. the window.onload is not being fired and i don't know why... For the moment, i've changed it to a simple function and i've called it just before the [/body] tag... now it's working.
Anyway, there is any working sample for using multi-upload into a simple form? i don't want to autostart the uploads, i just want to add it to the queue when i use the browse button, and then, when submit button is pressed, to start uploading all the queue...
regards,
January 30, 2009 - 1:51pm
The file uploads aren't submitted with the form like a normal upload. So you need an upload script to handle the file uploads. This is usually separate from the action target of the form which will process the form but not the upload.
On your submit button you wire it up so it calls startUpload(). You might also have it disable the browse button so they don't add more files in the middle the upload process (submitting a form while a browse window is open will crash most browsers).
Then, use the Queue Plugin to have SWFUpload automatically upload all queued files and use the QueueComplete event (from the queue plugin) to call your form.submit().
Then you just need to figure out what to do about upload error and/or form validation.
January 30, 2009 - 9:40pm
Many thanks again gyphie, so if i understood it well, i must use two php scripts, one for receiving the file uploads and then, another one to process the form. Now my question is, how can i know from the second script (the one wich processes the form) the filenames and paths to store them in my database??
Thanks
January 31, 2009 - 6:39pm
Your uploads will happen first so the upload script should be saving the files and making DB entries.
Then your form is submitted and the files and DB entries should already be there.
If that doesn't work for your application you can try using the addFileParam to add each form field value to the post that goes along with the upload and save the entire form and file together in the upload script.
Then you don't have to submit your form after the upload is done.
You have to start thinking of the app in an Ajax kind of way with asynchronous calls. It can get a bit complicated when you are uploading multiple files since each file is uploaded as a separate request (rather than all together like a normal form post).