Skip to content Skip to sidebar Skip to footer

Why Is This Perl Cgi Script Failing To Upload Images Correctly?

I have this code: use CGI; use File::Basename; use Image::Magick; use Time::HiRes qw(gettimeofday); my $query = new CGI; my $upload_dir = '../images'; #location

Solution 1:

You need to change

my $upload_filehandle =$query->param("img");

to

my $upload_filehandle =$query->upload("img");

according to this tutorial.

Hope it helps.

Solution 2:

I figured out why: As pointed out in the CGI.pm docs, the form's encoding type must be multipart/form-data. When I added that, everything worked.

Solution 3:

added this "ENCTYPE='multipart/form-data'" instead of encoding.

> <formaction="/post.pl"method="post"ENCTYPE='multipart/form-data'>

and it worked

Post a Comment for "Why Is This Perl Cgi Script Failing To Upload Images Correctly?"