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:


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

THanks David

On 17 Jun 2007, at 01:56, DavidB wrote:

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:

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

Best regards

Peter De Berdt

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

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.


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.