On Wed, 31 Jul 2002 15:17:56 +0300, [EMAIL PROTECTED] (Octavian Rasnita) wrote:
>I want to print another page that prints "File uploading..." while the file >is uploading. > >Unfortunately I can't do that. >After pressing the upload button, the page remains the same. It only appears >"Opening Page..." in the task bar. > >Only after the file is uploaded it prints the result page, even a part of >that page is printed before opening and printing the file. > >Do you have any idea why? Well I had to chop down, and slow your script up, to get it to run for me. I'm running this on my localhost, so I can't guess what happens over a serial connection. I'm guessing that your script is running so fast on the localhost, that everything appears "at once". I put a "select(undef,undef,undef,.05)" in there, so the dots would flow. I also had to reduce your buffer size to get more dots to appear. If you need to resort to these tricks to get it to work over a serial connection, I'm afraid all you are doing is slowing down your uploads, maybe you shouldn't use the upload progress meter? Like I said, this runs on my localhost, showing progress, but when I try the script from a machine on my LAN, it prints all the dots at once. There is probably buffering going on in the ethernet system. This is way too unpredictable to use. #up2.cgi ########################################################### #!/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 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title>Uploading the file...</title> </head> <body> <div class="center"> <div class="text_h1"> The file is uploading... </div></div> <br><br> 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; binmode $file; while (read($file, my $buffer, 1024)) { print OUT $buffer; #Print to the browser to prevent the timeout: print "."; select (undef,undef,undef,.05); } 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 } ################################################### #up2.html ###################################################### <html> <form enctype="multipart/form-data" method=post action=http://zentara.zentara.net/~zentara/cgi-bin/up2.cgi> <input type=file name=file > <INPUT TYPE="submit" VALUE="Send!"> </form> </html> ###################################################### -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]