On Thu, 01 Aug 2002 11:40:49 -0400, [EMAIL PROTECTED] (Zentara) wrote: Hi again, just to tell you I've had better luck with your script. I tried to flush the stdout when printing "."
I think the secret is to force a buffer flush with \n. I tried : select STDOUT; $|=1; print STDOUT "."; but it still buffered the dots when used over a LAN. I finally got it to work over my LAN with the following changes. I broke the while loop that does the reading up, so that each read is a separate event. Then I put a \n after the "." i.e. print ".\n". Even then the dots came out a line at a time. So I tried print "still uploading<br>\n". That does it, but it scrolls off bottom of screen. Anyways, it should work. The below script works, but you get an awful lot of messages, but it depends on file size. Anyways, it was fun trying to figure this out. :-) ######################################################## #!/usr/bin/perl -wT use strict; use CGI; my $q = new CGI; #The max size of the uploaded file: $CGI::POST_MAX = 1024 * 1024 * 30; my $maxfile = $CGI::POST_MAX; #The folder with the uploaded files: my $outfolder = "uploads"; &upload; sub upload { my ($filen, $ext); #Print the start of the page: $| = 1; print <<eof; Content-type: text/html Uploading the file... <body><html> eof my $file = $q->upload('file'); my $filename = $file; $filename =~ s/^.*\///g; $filename =~ s/^.*\\//g; $filename =~ s/\-/_/g; $filename =~ s/^\.*//g; $filename =~ s/ /_/g; my $allpath = $file; if ($filename =~ /\./) { $filen = $`; $ext = $'; } my $maxtries=4; for (my $i=1; $i < $maxtries; $i++) { if (-e "$outfolder/$filename") { $filename = $filen . "_" . $i . '.' . $ext; } } #Create the file on the server, and print the "." on the page: open(OUT, ">$outfolder/$filename") or die "Can't open $outfolder/$file for writing. - $!"; binmode OUT; while(1){ #while(read($file, my $buffer, 1024)){; read($file, my $buffer,4096); last unless $buffer; print OUT $buffer; print ".....still uploading....\n"; select (undef,undef,undef,.01); } close OUT; my $filesize = -s "$outfolder/$filename"; $filesize = (int(($filesize / 1024) * 10) / 10); $filesize = "$filesize KB"; #Print on the browser: my $script = 'http://zentara.zentara.net/~zentara/up2.html'; print <<eof; <br><br> The file $filename was successfully uploaded!<br> The file has $filesize.<br> <div class="center"> <a href="$script">Go back if you want to upload one more file.</a> <a href="/">Go to main page on Teddy Center!</a> </body></html> eof #End the subroutine } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]