Re: problem in file uploading

Hongliang Zhang
2007-11-16T02:12:50Z

Nadeesha Meththananda wrote:
> Akbar Home wrote:
>> On Nov 14, 2:45 pm, Nadeesha Meththananda
<rails-mailing-l...@andreas-
>> s.net> wrote:
>>> " You have a nil object when you didn''t expect it!
>>> The error occurred while evaluating nil.read"
>>>
>>> so if any body know where i have gone wrong ?????????
>>>
>>
>> Form_for is for object (when you pass activerecord object to view).
>> Use form_tag instead.
>
>
>
> sort it out the problem thanks.
>
> by the way do u guys know any command to check the file format.
>
>  eg like .doc, .pdf .jpg.

I think you can use

params["upload_file"].content_type to check the file format

eg.

params["upload_file"].content_type.chomp !~ /^image/

to check the upload file is image.