olly has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am trying to upload pictures with the following code

my $filename = make_filename(); my $fh = $q->upload("picture_location"); binmode(fh); open (OUT, ">$filename.jpg") || die "Can't open: $!"; while (<$fh>) { print OUT; } close OUT;
But then when I try to open the file after it is uploaded it gives me the error can't open file. Does anyone know what I am doing wrong?

Imagination is more important then knowledge -Einstein-

Replies are listed 'Best First'.
(ar0n) Re: image uploading in windows
by ar0n (Priest) on May 11, 2001 at 16:27 UTC
    You're missing a dollar-sign in binmode(fh), but that isn't the cause of your problem, afaik (unless you mean with "can't open file" that you can't view it in an editor). Can you give us the exact error message?

    Update According to your reply, in all likelyhood binmode(fh) is the problem. Try replacing it with binmode($fh)

    ar0n ]

      The error message is can't open file and photoshop just doesn't open it.

      Imagination is more important then knowledge -Einstein-

Re: image uploading in windows
by bjelli (Pilgrim) on May 11, 2001 at 17:59 UTC

    I can't tell what the problem is, but here are two hints for debugging:

    1. Output the filename somewhere in your script, it would be good to know what make_filename() did.
    2. make sure the form your data is coming from has enctype set to "multipart/form-data".
    --
    Brigitte    'I never met a chocolate I didnt like'    Jellinek
    http://www.horus.com/~bjelli/         http://perlwelt.horus.at