Hi to all,
i’m trying to upload a pdf or doc file on my server.
My code works under linux, but now i move my app to a windows server and
the documents (both pdf and doc) are not uplaoded correctly.
Here it’s my form code in the view:
<%= form_tag( { :action => ‘create’ }, :multipart => true ) -%>
Cv
<%= file_field 'nominee', 'cv' %>
<%= submit_tag “Next” %>
and this is my controller:
if(@nominee.cv != “”)
[email protected] rescue nil
ext=file_field.original_filename.to_s.split('.')
File.open("#{$path}/public/cv/#{@nominee.id}.#{ext[1]}", "w") { |f|
f.write(file_field.read)}
@nominee.cv="/cv/#{@nominee[:id]}.#{ext[1]}"
end
Can anybody help me???
Thanks in advance
Andrea
On 16 Jun 2008, at 10:59, Andrea C. wrote:
Is $path what you think it is ? Where are things breaking down ?
Fred
On 16 Jun 2008, at 11:15, Andrea C. wrote:
And it seems coorect also the uploading of the file, i mean that there
are no exception raised by Rails…
But after, when i try to dowload the file i can’t open it because it
is
corrupted…
windows might be one of those weird operating systems where ‘open in
binary mode’ actually means something. (so pass wb as the file mode
when creating)
Fred
Frederick C. wrote:
On 16 Jun 2008, at 10:59, Andrea C. wrote:
Is $path what you think it is ? Where are things breaking down ?
Fred
The $path is correct the file is saved in the correct folder…
And it seems coorect also the uploading of the file, i mean that there
are no exception raised by Rails…
But after, when i try to dowload the file i can’t open it because it is
corrupted…
thanks Fred