# Flash Filereference and Rails - getting http 422

**URL:** <https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365>\
**Category:** Rails\
**Created:** [May 7, 2009, 2:19am UTC](https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365 "2009-05-07T02:19:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 7, 2009, 2:19am UTC](https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365/1 "2009-05-07T02:19:37Z")

</div>

I’ve spent the last few days trying to figure this out. I have my own  
Filereference class I use with PHP. But I’m trying to use it with  
Rails and can’t seem to get it to work. I even downloaded some samples  
online and can’t get those to work ([http://blog.vixiom.com/2006/09/08/](http://blog.vixiom.com/2006/09/08/)  
multiple-file-upload-with-flash-and-ruby-on-rails/).

Basically my rails is something like this:

```
data = params[:filedata]
name = params[:Filename]

directory = "public/data"

  path = File.join(directory, name)
  File.open(path, 'wb') do |file|
    file.puts data.read
  end

```

And when I use filereference and upload it in flash I get an  
httpError: 422  
I get this both in mine and the example’s file.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 8, 2009, 6:00pm UTC](https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365/2 "2009-05-08T18:00:15Z")

</div>

Anyone know what the answer might be? Or an up to date link that  
explains?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 8, 2009, 8:53pm UTC](https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365/3 "2009-05-08T20:53:11Z")

</div>

Hmm. I think it may be something with the Authenticity Token. I think  
I need to bypass it…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 9, 2009, 1:06am UTC](https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365/4 "2009-05-09T01:06:01Z")

</div>

K I figured out how to fetch and send the AuthToken… It’s still now  
working.

Anyone have any idea, or a resource for Flash file uploading to Rails  
2.x?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 9, 2009, 6:03pm UTC](https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365/5 "2009-05-09T18:03:16Z")

</div>

Have you tried the “Flash 8 for Windows” fix on the blog page you  
linked? Without any more details about your environment, that’s the  
first thing I’d suspect. Not sure how that fix will interact with the  
new Rack stuff in 2.3, though.

–Matt J.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 9, 2009, 8:16pm UTC](https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365/6 "2009-05-09T20:16:53Z")

</div>

I didn’t, but I’m running on a Mac, so I figured it wouldn’t matter…  
Plus that post is 3 years old!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 9, 2009, 3:03am UTC](https://www.ruby-forum.com/t/flash-filereference-and-rails-getting-http-422/167365/7 "2009-05-09T03:03:34Z")

</div>

oops, I meant still NOT working\*\*

Any ideas?
