I'm a monk. I have a form field to allow me to upload a picture. Every picture I upload is smaller than 80k, is a .gif a .jpg or a .png, and is narrower than 350 pixels. However, every time I try uploading a picture, I get an error messaging saying it doesn't appear to be a .gif file.

Can anyone help me, or at least tell me why this won't work for me when it seems to work for all other monks and up?

Replies are listed 'Best First'.
(tye)Re: What's wrong with this picture?
by tye (Sage) on Nov 09, 2001 at 03:09 UTC

    I'll bet you are uploading .GIF, .JPG, and/or .PNG files.

    Update: That is, I looked at the source code that lets you upload images to PerlMonks and it is case sensitive. I've submitted a patch to change that. vroom was been pretty quick to notice and apply my previous patch, but this isn't as serious of a problem so I wouldn't suggest that you hold your breath.

    Instead, rename the extension of your file to lower case or just type it in lower case in the box that asks for the file you want to upload (though this second option may not work if your browser overrides the letter case of what you typed with the letter case of the name of the file that it found).

            - tye (but my friends call me "Tye")
      That does not appear to be the issue. When I transfer the file to a Linux box (yes, my office workstation is Windows until I get time free to change that) the whole filename is lower-cased, just like on the Windows box. In fact, I checked for the same thing before, and other known Windows issues such as funky path resolution (I used the DOS six-plus-tilde-plus-number versions of the directory names and everything, to no avail).

      I think I've even tried multiple browsers, but I can't recall for sure.

        Hmm, I think I misread the code. Here is a bigger chunk:

        my $content = $query->uploadInfo($fname)->{"Content-Type"}; unless ($content =~ /(jpeg|gif|png)$/) { return "this doesn't look like a jpg or gif!" } $imgname .= ".".$1;
        which means that your problem is probably that the uploaded image doesn't have the proper Content-Type header? I didn't think that HTTP file uploads had Content-Type headers, but I probably wouldn't know such things.

        Anyway, that gives you something to look into. (BTW, $query is a CGI.pm object and I did some checking and it really does appear to be checking the header information.)

                - tye (but my friends call me "Tye")
      My picture, which I was trying to upload today, was definitely a lower case '.gif'. Are there other factors in the naming convention? - e.g. my browser filled in "D:\pmpic.gif", (I'm on a Win32 box) I tried without quotes and also with forward-slash instead. Still no joy.

      Cheerio!
      Osfameron

        Well, the code that generates that particular error is:

        unless ($content =~ /(jpeg|gif|png)$/) { return "this doesn't look like a jpg or gif!" }
        so I don't see any other obvious problems.

        The "D:" says you are probably on Windows which means that your browser could certainly be replacing the letter case of what you type with the letter case of the name of the file.

        And if you have a file whose name is all upper case, then Windows has an annoying habbit of displaying that file name in lower case or simply capitalized. So you might try renaming the file so that the first part of the name contains some capital letters (not counting the first letter).

                - tye (but my friends call me "Tye")