Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file uploading 1

Status
Not open for further replies.

teroy

Programmer
Oct 17, 2000
67
0
0
AU
Hi I'm using the following to upload a file to a server. But anything over a
1 meg does not go thru. Does anyone know why? I have increased the buffer
size to more than 1024.

Thanks in advance

Html bit
<snip>
<form action=mytest.cgi method=post ENCTYPE=&quot;multipart/form-data&quot;>
<input type=hidden name=action value=upload>
<input type=&quot;file&quot; name=&quot;fileToGo&quot;><br><br>
<input type=submit name=import>
</form>

Perl Bit
<snip>
open (OUTFILE, &quot;>$fileName&quot;);
while (my $bytesread = read($file, my $buffer, 1024)) {
print OUTFILE $buffer;
}
close (OUTFILE);
 
more to that..

It works in Netscape

only screws up in IE!!

damn you IE hehe
 

What are you talking about, NS is the one that blows. hehe.

Well, From what you've shown it looks like there shouldn't be any problem to me, I've got an upload script laying around on my hard drive though, I'll paste it and maybe you'll find your answer there.

I wrote it for a friend, It'll upload 2mb with no problem also.

Tony

PS. I just tested the following code and 2.01mb went up with no difficulties and it doesn't look like IE has a file transfer limit. Maybe you have an older version of Ie??

#!/usr/bin/perl
use CGI qw/:standard :html3/;
print &quot;Content-type: text/html\n\n&quot;;
$upload_dir = &quot;path/to/dir&quot;;
$upload = param('upload');
$do = param('do');
$name = &quot;$upload&quot;;
$name =~ s!^.*(\\|/)!!;
$file = param('upload');
$file =~ m!([^/:\\]*)$!;
$short_name = $1;
open (SAVE,&quot;>$upload_dir/$short_name&quot;);
while ($size = read($file,$data,1024)){
print SAVE $data;
$total_size += $size;
}
close SAVE;
print &quot;Done Uploading Your File&quot;;




#####################################################################################
# HTML FORM

ENCTYPE=&quot;multipart/form-data&quot;

Is the killer line most people forget, whenever you are making an upload program
and it creates the file, but is emtpy, you left out this line in the form.

Never Forget this line! ENCTYPE=&quot;multipart/form-data&quot;

#####################################################################################
<form method=&quot;POST&quot; ENCTYPE=&quot;multipart/form-data&quot; action=&quot;upload.cgi&quot;>
<p align=&quot;center&quot;>
<font color=&quot;#FFFFFF&quot;>
<input type=&quot;file&quot; name=&quot;upload&quot; size=&quot;33&quot;>
<input type=&quot;submit&quot; value=&quot; Upload &quot; name=&quot;B1&quot;></font></p>
</form>
 
Thanks Tony...I got it working..wasn't a perl fault at all..doh!
Reason being that my proxy server does not allow uploads of over 1 meg. Configured in Squid. Argh. So i bypassed the proxy and it worked fine

Stoopid me hehe
 

It's ok, Glad you got it worked out Mate,

Netscape must die!

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top