search for: sanitize_filenam

Displaying 12 results from an estimated 12 matches for "sanitize_filenam".

Did you mean: sanitize_filename
2006 Jun 20
2
Problem with "can''t dump anonymous class Class"
...else File.open(self.file_path, "wb") { |f| f.write(@uploaded_file.read) } end end def after_destroy if File.exists?(self.file_path) File.delete(self.file_path) end end def file=(uploaded_file) @uploaded_file = uploaded_file self.file_path = sanitize_filename(@uploaded_file.original_filename) self.content_type = @uploaded_file.content_type end private def new_filename(file_name) idx = file_name.rindex "." self.name.gsub(/[^\w\.\_]/, ''_'') + file_name[idx, file_name.length - idx] end def sanitize_fi...
2006 Jan 09
1
Saving an upload
...e), "File upload failed" end end def uploaded_file=(incoming_file) self.filename = incoming_file.original_filename self.content_type = incoming_file.content_type @temp_file = incoming_file end def filename=(new_file_name) write_attribute("filename", sanitize_filename(new_file_name)) end private def sanitize_filename(file_name) # get only the filename, not the whole path (from IE) just_filename = File.basename(file_name) # replace all non-alphanumeric, underscore or periods with underscores just_filename.gsub(/[^\w\.\-]/,''_'...
2006 Jun 19
3
can''t dump anonymous class Class
...) else File.open(self.file_path, "wb") { |f| f.write(@uploaded_file.read) } end end def after_destroy if File.exists?(self.file_path) File.delete(self.file_path) end end def file=(uploaded_file) @uploaded_file = uploaded_file self.file_path = sanitize_filename(@uploaded_file.original_filename) self.content_type = @uploaded_file.content_type end private def new_filename(file_name) idx = file_name.rindex "." self.name.gsub(/[^\w\.\_]/, ''_'') + file_name[idx, file_name.length - idx] end def sanitize_filen...
2006 May 02
0
Validation in File Upload
...h[:notice] = "Added a newsletter: #{@newsletter.name}" redirect_to(:action=>''newsletter'') end end ----MODEL---- class Newsletter < ActiveRecord::Base validates_presence_of :name, :summary, :filename def newsletter=(newsletter_field) self.filename = sanitize_filename(newsletter_field.original_filename) self.filename = Time.now.strftime("%H%M%S")+self.filename #self.data = element_field.read File.open("#{RAILS_ROOT}/public/newsletters/#{self.filename}","wb") { |f| f.write(newsletter_field.read)} end private def saniti...
2006 Jan 15
4
model helper location
Hi, I''m looking at the rails cookbook for uploading files[1]. At the bottom of the page it says that the sanitize_filename functioin would probably go in a helper or a library. I wonder where these files would be or what they would be called. Pehaps there are some conventions I need to know about? Thanks, Peter [1] http://manuals.rubyonrails.com/read/chapter/78
2007 Jan 18
1
Internet Explorer - Sanitize Uploaded Filenames
...E, it prepends the entire path. C:\My Documents\User\Desktop\Document.doc Which makes the file unreadable, and un-downloadable. I know that the sanitize method is supposed to fix this, but I can''t figure out how to make it work. Here is what I''ve written in my model: def self.sanitize_filename(filename) filename = File.basename(filename.gsub("\\", "/")) filename.gsub(/[^a-zA-Z0-9\.\-\+_]/,"_") end Doesn''t work. What do I need to do? This is bugging me so much. --~--~---------~--~----~------------~-------~--~----~ You received this message...
2006 Jul 07
7
file_column repository broken?
I really want to try out file_column but the repository seems to be down for me. I added it to my repository list and script/plugin is unable to see anything in it. I downloaded an archive from the website but it is not clear to me which files need to be installed to which subdirs of my RoR project. Anyone else having this issue with the repository? I am able to see other repositorys no
2006 Jun 08
1
Permissions on uploaded files, TinyFile
Hi, im getting a little trouble with this, im using TinyFile as the example to upload files http://wiki.rubyonrails.com/rails/pages/TinyFile/versions/20 All goes well but the files uploaded are saved with permissions 600 (linux) and in the case of images arent showed on the browser(but uploaded and stored in the server without problems) i have to manually ftp to the uploaded files folder and
2006 Jan 06
4
Upload Progress Bar Problems
I''m writing an application where the user will be uploading many images and user feedback is essential. I''ve been trying to get the upload progress bar plug-in to work, but thus far have not had any success. I''ve downloaded Sean Treadway''s application code from his site http://sean.treadway.info/demo/upload/ and I followed the steps in his Upload
2006 Mar 29
7
Uploading files and writing them to server?
Where should I look for information on how to use Rails and Ruby to accept the upload of a file and then to save that file to the file system of my server? I''m reading the "Uploading a file" section of Agile Web Dev with Rails, but it''s geared toward saving the file in the database. Any advice? Thanks, Jeff -- Posted via http://www.ruby-forum.com/.
2009 Jul 29
0
Problem uploading file to database mysql blob field
...to copy the file content into the blob. I updated attachment.rb , just added the line self.file = @temp_file.read as I need to read the content of file and put it into database. def file=(incoming_file) unless incoming_file.nil? @temp_file = incoming_file if @temp_file.size > 0 self.filename = sanitize_filename(@temp_file.original_filename) self.disk_filename = Attachment.disk_filename(filename) self.content_type = @temp_file.content_type.to_s.chomp self.filesize = @temp_file.size self.file = @temp_file.read end end end But After doing so I am getting the following error: Anybody please give some direct...
2006 Jan 22
12
Problems with File_column
Hi, Rails - newbie here.. I''m setting up an app and am trying to use file_column to upload a picture with an item and I''m running into several problems. (Background: I''m running Locomotive Rails under OS X 10.4.4, and using Safari) I followed the directions to add the necessary items, then found out that I had to add the item to make the form tag be a multipart