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 ) -%> <p><label for="nominee_cv">Cv</label><br/> <%= file_field ''nominee'', ''cv'' %></p> <%= submit_tag "Next" %> </form> and this is my controller: if(@nominee.cv != "") file_field=@nominee.cv 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 16 Jun 2008, at 10:59, Andrea Campagna wrote:> > if(@nominee.cv != "") > file_field=@nominee.cv 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 >Is $path what you think it is ? Where are things breaking down ? Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 16 Jun 2008, at 10:59, Andrea Campagna wrote: >> > Is $path what you think it is ? Where are things breaking down ? > > FredThe $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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 16 Jun 2008, at 11:15, Andrea Campagna wrote:> > > Frederick Cheung wrote: >> On 16 Jun 2008, at 10:59, Andrea Campagna 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.... >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> thanks Fred > > > > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 16 Jun 2008, at 11:15, Andrea Campagna 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) > > FredGREAT IT WORKS !!!!! REALLY THANKS !!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---