Już od dłuższego czasu próbuję napisać pasek postępu, przepatrzyłem praktycznie cały internet i wszystkie możliwości, jednak nie znalazłem żadnego działającego rozwiązania.
Więc postanowiłem spróbować z perlem, oto mój kod uploadu:
#!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI(); # Handle actions. if ($q->param('action') eq "upload") { # They just submitted the form and are sending a file. my $filename = $q->param('file'); my $handle = $q->upload('file'); $filename =~ s/(?:\\|\/)([^\\\/]+)$/$1/g; # File size. my $size = (-s $handle); # This session ID would be randomly generated for real. my $sessid = 'my-session'; # Create the session file. close (CREATE); # Start receiving the file. while (<$handle>) { } # Delete the session. # Done. } elsif ($q->param('action') eq "progress") { # They're checking up on their progress; get their sess ID. my $sessid = $q->param('session') || 'my-session'; # Does it exist? if (!-f "./sessions/$sessid") { } # Read it. open (READ, "./sessions/$sessid"); my $line = <READ>; close (READ); # Get their file size and name. my ($size,$name) = $line =~ /^size=(\d+)&file=(.+?)$/; # How much was downloaded? my $downloaded = -s "./files/$name"; # Calculate a percentage. my $percent = 0; if ($size > 0) { $percent = ($downloaded / $size) * 100; $percent =~ s/\.(\d)\d+$/.$1/g; } # Print some data for the JS. } else { }
Serwer zwraca jednak następujący błąd: couldn't create child process: 720003: upload.cgi
Z góry dziękuję za pomoc, bardzo mi na tym zależy, ewentualnie jeśli ktoś zna inny sposób na pasek postępu, również będę wdzięczny.
Pozdrawiam.