Upload File Corruption Error

Hello All,

I've been reading a lot of blogs/tutorials on how to go about
uploading files to a server via a form in my application - they all
pointed me in the direction that "File.open(self.path, "wb") { |f|
f.write(@uploaded_file.read) }" is what will write the file to the new
location on the server.

I've tried this over and over again an each time the file moves over
to the new location on my computer but the file becomes corrupt. Files
don't contain the data it should and pictures don't open.

I'm working on trying to use attachment_fu and other plugins that
people have been raving about but in the mean time I thought to throw
this problem at you guys and see if anyone else came across this issue
and how they may have resolved it.

(In case you are curious I need to be able to upload files like docs
pdfs images zips to the server - the database will contain the
filename and location.)

So, has anyone had their files corrupt in their attempts to upload
files to their server?


are you using Windows? such problems are common in this
OS. for reading a file, for example, you must use
an 'rb' parameter (e.g. "File.open(path, 'rb')"), so
perhaps there is some Windows requirement that you
are missing.

Thank you for replying!

I am working on a Macintosh. It gives me an error

No such file or directory - /Users/mariam/Documents/intervu/public/
data/artifacts/0714081149-Picture 1.png

when I replace wb with rb. I'm going to research uploading files on
macs instead.