From: Carlos Date: 2005-01-07T01:06:47+09:00 Subject: Re: Image decompression, eruby [Belorion , 2005-01-06 16.37 CET] [...] > Specifically, my HTML for uploading looks like: > >
action='attach.rhtml' method='post'> > > > > > > And my upload specific ruby in attach.rhtml looks like: > > fromfile = cgi.params['myfile'].first > fromfile.binmode # Tried both with and without this line > dbh.do( "INSERT INTO attachments VALUES( ? )", [ index, > fromfile.original_filename, fromfile.read] ) > > So, somewhere in that process the data gets corrupted, and the image > comes out half garbled. Any ideas? Plain text files, which are > handled using the exact same script, come out just fine. I don't have any idea about dbi or mysql... Attacking the problem by the web side :), maybe the upload got interrupted and you are getting a truncated file. If you add a parameter like at the end of your form, you can check it to know if all the previous fields arrived whole. At least, if that's not the problem, you'll have a variable less to ponder (and it is a good general tip, too :).