Baffled on the most simple file upload issue

In my site visitors can upload photos, and of course I have the typical
file type validation. I only allow files that are jpegs as seen in this
script, but when I attempt to upload jpegs with that same file type, it
gives me the error message I programmed if the content type is not
image/jpeg, but in he same error message, the system tells you what file
type it is if it isn’t image/jpeg, and my error read: “Only JPEG files
are allowed. This file is image/jpeg .” I don’t get it. If the system
confirmed it was an image/jpeg, then how come @file_type == ‘image/jpeg’
doesn’t return true, and return no error? What’s wrong with my code?
@file_type = params[:account][:picture].content_type
if @file_type == ‘image/jpeg’
# good
else
if @error == true
@error_content += ’ Furthermore, only JPEG files are allowed. This
file is #{@file_type}.’
else
@error_content += “Only JPEG files are allowed. This file is
#{@file_type}.”
end
@error = true
end
Thanks,
Ben

Interesting… Somehow either Firefox or apache escaped/ added /r to the
content_type…It’s Solved.

what was the fix?

On 8/22/06, Ben [email protected] wrote:

Interesting… Somehow either Firefox or apache escaped/ added /r to the
content_type…It’s Solved.


Posted via http://www.ruby-forum.com/.

www.blogsaic.com
search, post, blog

Dion H. wrote:

what was the fix?

I’m guessing he typed

@file_type = params[:account][:picture].content_type.chomp

Instead of

@file_type = params[:account][:picture].content_type