Forum: Ruby on Rails SWFUpload problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
8e01a4d029c6073279ae7287665d5550?d=identicon&s=25 DavidB (Guest)
on 2007-06-17 01:57
(Received via mailing list)
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
  <script type="text/javascript">

    var swfu;
    var swfu2;

    window.onload = function() {

      // Max settings

      swfu = new SWFUpload({
        upload_script: "
        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



THanks David
00973881979aa0a660ffbbb2f7a907fb?d=identicon&s=25 Peter De Berdt (Guest)
on 2007-06-17 11:59
(Received via mailing list)
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
8e01a4d029c6073279ae7287665d5550?d=identicon&s=25 DavidB (Guest)
on 2007-06-17 16:48
(Received via mailing list)
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.

8e01a4d029c6073279ae7287665d5550?d=identicon&s=25 DavidB (Guest)
on 2007-06-17 17:37
(Received via mailing list)
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.
This topic is locked and can not be replied to.