# SWFUpload problem

**URL:** <https://www.ruby-forum.com/t/swfupload-problem/107039>\
**Category:** Rails\
**Created:** [June 17, 2007, 1:57am UTC](https://www.ruby-forum.com/t/swfupload-problem/107039 "2007-06-17T01:57:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [June 17, 2007, 1:57am UTC](https://www.ruby-forum.com/t/swfupload-problem/107039/1 "2007-06-17T01:57:10Z")

</div>

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:](https://www.example.com/app/controller/form_for_upload:)

THanks David

---

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [June 17, 2007, 11:59am UTC](https://www.ruby-forum.com/t/swfupload-problem/107039/2 "2007-06-17T11:59:52Z")

</div>

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  
upload\_error\_callback.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [June 17, 2007, 4:48pm UTC](https://www.ruby-forum.com/t/swfupload-problem/107039/3 "2007-06-17T16:48:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [June 17, 2007, 5:37pm UTC](https://www.ruby-forum.com/t/swfupload-problem/107039/4 "2007-06-17T17:37:38Z")

</div>

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
