By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,830 Members | 1,758 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,830 IT Pros & Developers. It's quick & easy.

IE file upload problem

P: 1
I have a very simple form and perl script that is to upload a jpg file. I am not familiar with the perl language but copied the code from a text book.

It works fine with all browsers except IE. !!!!!

The code is able to validate that it is a jpg but never gets to the debugging statement 'in loop"

I have seen numerious complaints via google searches about IE and uploads but
am unable to decipher the solution.

Any help will be GREATLY appreciated.



============= HTML CODE ============================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<HTML [5]>
<HEAD></HEAD>
<BODY>
<FORM ACTION="/cgi-bin/upload2.cgi" METHOD="post" ENCTYPE="multipart/form-data">
Image to upload:......
<INPUT TYPE="file" NAME="uploadfile" size="50">
<br><br>
Your Email Address: <INPUT TYPE="text" NAME="email_address">

<br><br>
Enter Password:.......
<INPUT TYPE="text" NAME="vps_password">

<br><br>
<input type="submit" name="Submit" value="Submit Form">
</BODY>
</HTML>




============== PERL SCRIPT CODE ===============================


#!/usr/bin/perl -w

use strict;
use CGI ':standard';

print "Content-type: text/html\n\n";

print "Preparing to upload your image. Must be type jpg and LE 1M. ";

print "step 1";
my $file= param('uploadfile');

print "step 2";
my $info= uploadInfo ($file);

print "step 3";
my $type= $info -> {'Content-Type'};

my $vps_password;

$vps_password = param ('vps_password');

if ($vps_password eq 'vienna') {
print "<p> password ok";
} else {
print "<p> Invalid Password. Call Sharon." || Error3 ();
exit;
}




$file =~ s/.*[\/\\](.*)/$1/;



if ($file) {


# open (UPLOAD, ">C:/vps-va/uploadphoto/$file") || Error ();
open (UPLOAD, ">../uploadphoto/$file") || Error ();

binmode UPLOAD;

my $info = uploadInfo($file);
my $type= $info->{'Content-Type'};

print "<p>You want to upload
<b>$file</b> with a MIME type of
<b>$type<b>";


if ($file =~ /\.jpg/ or $file =~ /\.JPG/ ) {

print "<p>starting to upload";

my ($data, $length, $chunk);
while ($chunk = read ($file, $data, 1024)) {
print "in loop";
print UPLOAD $data;

$length += $chunk;
if ($length > 1024000) {
print "<p> That image is too big. The limit is 1 Meg. I'm deleting.";
# unlink ("C:/vps-va/upload/$file") || Error2 ();
unlink ("../uploadphoto/$file") || Error2 ();
exit;
}
}
close (UPLOAD);
print ("<p> Upload of $file was successful. Size was $length bytes.");

} else {

print "<p>Must be jpg. Image not uploaded.";
unlink ("../uploadphoto/$file") || Error2 ();
}
} else {
print "<p> No file was chosen.";
}

sub Error {
print "Error routine 2.1 could not open";
print "Couldn't open temporary file: $!";
exit;
}
sub Error2 {
print "Couldn't delete file: $!";
exit;
}
sub Error3 {
print "Bad Password";
exit;
}
Nov 29 '06 #1
Share this Question
Share on Google+
1 Reply


P: 83
I'm the author of a Perl module for facilitating file uploads: CGI::UploadEasy. It has not been reported to have the limitation you mention.
Nov 30 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.