SWFUpload problem

I am trying to use SWF Upload to upload images to my rails application

WHen I try to upload a file using a normal HTML upload form, it works just fine. In other words, the upload method in my controller reads the file and writes it to the disk.

However, when I use SWF Upload, I get no errors, the DHTML returned= 'files uploaded', but nothing is written to the server's disk. In fact, I can make several nonsensical modifications to the 'upload_script' variable, and no errors are raised, but still no file upload. I suspect this is a relative path issue.

How do you modify your path to upload_script so that you get an upload, or do you put your files in a different directory structure from that specified below:

Thanks-David

I am using SWFUpload with the following structure:

app directory/public/javascripts/jscripts/SWFUpload/SWFUpload.js app directory/public/javascripts/jscripts/SWFUpload/SWFUpload.swf

example config javascript in side of my upload form https://www.example.com/app/controller/form_for_upload:   <script type="text/javascript">

    var swfu;     var swfu2;

    window.onload = function() {

      // Max settings

      swfu = new SWFUpload({         upload_script: "https://www.example.com/app/controller/ file_upload_method",         target : "SWFUploadTarget",         flash_path : "/javascripts/jscripts/SWFUpload/SWFUpload.swf",         allowed_filesize : 30720, // 30 MB         allowed_filetypes : "*.*",         allowed_filetypes_description : "All files...",         browse_link_innerhtml : "Browse",         upload_link_innerhtml : "Upload queue",         browse_link_class : "swfuploadbtn browsebtn",         upload_link_class : "swfuploadbtn uploadbtn",         flash_loaded_callback : 'swfu.flashLoaded',         upload_file_queued_callback : "fileQueued",         upload_file_start_callback : 'uploadFileStart',         upload_progress_callback : 'uploadProgress',         upload_file_complete_callback : 'uploadFileComplete',         upload_file_cancel_callback : 'uploadFileCancelled',         upload_queue_complete_callback : 'uploadQueueComplete',         upload_error_callback : 'uploadError',         upload_cancel_callback : 'uploadCancel',         auto_upload : false       });

    }

  </script>

THanks David

Everything seems quite in order in your config. I’m guessing you use <%= url_for … -%> to generate the url for the upload script?

Anyhow, I’m using SWFUpload a fair number of applications without a problem. SWFUpload on the client side, acts_as_attachment or attachment_fu on the serverside. The only thing I had to do, is map the file extension (.jpg, .png, …) to the content-type (image/jpeg, image/png, …), because flash streams everything as octet-stream.

Could you post your upload script? I’m guessing the problem is in your serverside script, if you’re not getting in error in the upload_error_callback.

Best regards

Peter De Berdt

Peter, THanks. I actually figured it out. The main problem was not with the script or the call to the script. After reviewing the web server logs (two hours into this foray!!), I found that Flash was calling the upload script properly, but the response from the server was the login page. Amazing how hard this was to find and thus debug!! I wen through the javascript method by method and my ruby line by line, but basically it appears that because my application requires authentication, and it sees the Flash calls as un-authenticated, it stops any upload. This took two seconds to fix when I realized the problem.

So I hope this may be of use to others when using authentication. ANd thanks to you Peter.

I do have some other points I would like to bring up.

1. I love how quick and seemingly magical the SWFUpload works on my sight, but for a while I kept getting "Error IO messages", and eventually figured out this was because I needed to get an up to date Flash plugin for my browser. THis could be a big problem if not addressed. Any way of other than telling all users that they must download the plugin before proceeding to upload, or changing the Error IO message to "Upload a Flash plugin first"? In other words, is there some way to just detect whether or not a user has Flash?

2. Wouldn't an IFRAME alternative be more fool-proof?

Peter thanks again-after googling this topic, your name came up several times. Unfortunately, my initial problem was actually related to my server configuration.

David

Ignore the Flash Detect point-that is easily solved with javascript. I still wonder if an IFRAME approach would require the least configuration on the end user's part. Curious to hear opinions. David