On 18 November 2012 18:20, Akvarel <[email protected]> wrote: > Hello! > > I am using this example for file uploader. > Before uploading a file I would like to open it, search for a specific word, > assign this word to an attribute in the database and only then save the file > in the database. > > Example: > I select two files and click "upload" > The file name is assigned to a upload_file_name. > File's size is assigned to an upload_file_size. > File is opened, I search for a word "Bug" or "Lion". > If i find "Lion", "Lion" should be assigned to an upload_content_type. If I > find "Bug", "Bug" should be assigned to upload_content_type. > > I am not quite sure where I have to define the function that will open a > file: in uploads_controller.rb or in uploads.rb? And I do not know how to > assign a "Bug" to an upload_content_type.
All rb files are executed in the server. If you want to check the file *before* uploading it you will have to do it in the client pc, presumably in javascript. I don't know whether this is even possible, I doubt it. Do you think it would be a good thing if a web page could look inside files on your pc? I think you will have to upload it and then do the work. Are you a beginner at rails? If so then I suggest you work through a good tutorial such as railstutorial.org (which is free to use online). Colin -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

