CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
simple progress bar in my script

 



gerble1000
User

Aug 15, 2012, 3:38 AM

Post #1 of 1 (1021 views)
simple progress bar in my script Can't Post

i have an upload script with about 8 images and it can take up to 5 minutes of uploading and the user has no idea whats going on.
could somebody help me put a code into this script to show some sort of loading. even if its just
image 1 loaded
image 2 loading
image 2 loaded

and so on
here is my script


Code
 
#!/strawberry/perl/bin/perl -w



use CGI::Carp qw( fatalsToBrowser );

#print "Content-Type: text/html\n\n";
#print "Content-Type: text/plain\n\n";
#print "Content-Type: text";


#######################################################################################
my $domainname = "mydomainname";
use CGI qw/ :standard /;

use DBI;

use File::Copy;
use File::Basename;
use CGI;
use strict;
use warnings;
use Image::Resize;




my $sold = param('group2');


my $result1 = param('advert');


my $result2 = param('car');
my $result3 = param('price');
my $result4 = param('year');
my $result5 = param('fuel');
my $result6 = param('color');
my $result7 = param('mileage');
my $result8 = param('gearbox');
my $result9 = param('engine');
my $result10 = param('body');
my $result11 = param('desc');
my $result12 = param('available');

my $result13 = param('group1');
my $result14 = param('model');
my $result15 = param('colortext');


if ($result6 eq "Other" )
{
$result6 = "$result15";
}



if ($sold eq "blank" )
{
$sold = "";
}

if ($result12 eq "blank" )
{
$result12 = "";
}




if ($result14 eq "" )
{
$result14 = "Not Specified";
}





if ($result13 eq "Just" )
{
goto JUST;
}


else
{


goto JUST0;
}



JUST0:


if ($sold eq "No" )
{
goto SKIP0;
}


else
{
open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/available.txt");
print F "$sold";
close F;

goto SKIPend;
}




SKIP0:


open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/car.txt");
print F "$result2";
close F;

open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/price.txt");
print F "$result3";
close F;


open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/year.txt");
print F "$result4";
close F;


open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/fuel.txt");
print F "$result5";
close F;

open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/color.txt");
print F "$result6";
close F;

open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/mileage.txt");
print F "$result7";
close F;

open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/gearbox.txt");
print F "$result8";
close F;

open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/engine.txt");
print F "$result9";
close F;

open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/body.txt");
print F "$result10";
close F;


open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/desc.txt");
print F "$result11";
close F;

open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/available.txt");
print F "$result12";
close F;

open(F, '>:utf8', "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/model.txt");
print F "$result14";
close F;



if ($result13 eq "No" )
{

goto SKIPend;
}


JUST:




$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$result1";

my $query = new CGI; my $filename = $query->param("uploadfile1");

if ($filename eq "" )
{
copy("noimage.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/1.png");
copy("noimagethumb1.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb1.png");

goto SKIP1;
}



my $upload_filehandle = $query->upload("uploadfile1");
open ( UPLOADFILE, ">$result1/file.jpg" ) or die "failed to open '$upload_dir/1.jpg' $!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
copy("$result1/file.jpg","$result1/thumb1.jpg");
system("PhotoResize700x500ICO.exe $result1/file.jpg");
system("PhotoResize140x100ICO.exe $result1/thumb1.jpg");
move("$result1/file.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/1.png");
move("$result1/thumb1.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb1.png");




SKIP1:

$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$result1";

my $query = new CGI; my $filename = $query->param("uploadfile2");

if ($filename eq "" )
{
copy("noimage.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/11.png");
copy("noimagethumb1.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb11.png");
goto SKIP2;
}

my $upload_filehandle = $query->upload("uploadfile2");
open ( UPLOADFILE, ">$result1/file.jpg" ) or die "failed to open '$upload_dir/1.jpg' $!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
copy("$result1/file.jpg","$result1/thumb1.jpg");
system("PhotoResize700x500ICO.exe $result1/file.jpg");
system("PhotoResize140x100ICO.exe $result1/thumb1.jpg");
move("$result1/file.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/11.png");
move("$result1/thumb1.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb11.png");

SKIP2:


$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$result1";

my $query = new CGI; my $filename = $query->param("uploadfile3");

if ($filename eq "" )
{
copy("noimage.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/111.png");
copy("noimagethumb1.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb111.png");
goto SKIP3;
}

my $upload_filehandle = $query->upload("uploadfile3");
open ( UPLOADFILE, ">$result1/file.jpg" ) or die "failed to open '$upload_dir/1.jpg' $!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
copy("$result1/file.jpg","$result1/thumb1.jpg");
system("PhotoResize700x500ICO.exe $result1/file.jpg");
system("PhotoResize140x100ICO.exe $result1/thumb1.jpg");
move("$result1/file.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/111.png");
move("$result1/thumb1.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb111.png");


SKIP3:


$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$result1";

my $query = new CGI; my $filename = $query->param("uploadfile4");

if ($filename eq "" )
{
copy("noimage.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/1111.png");
copy("noimagethumb1.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb1111.png");
goto SKIP4;
}

my $upload_filehandle = $query->upload("uploadfile4");
open ( UPLOADFILE, ">$result1/file.jpg" ) or die "failed to open '$upload_dir/1.jpg' $!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
copy("$result1/file.jpg","$result1/thumb1.jpg");
system("PhotoResize700x500ICO.exe $result1/file.jpg");
system("PhotoResize140x100ICO.exe $result1/thumb1.jpg");
move("$result1/file.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/1111.png");
move("$result1/thumb1.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb1111.png");


SKIP4:


$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$result1";

my $query = new CGI; my $filename = $query->param("uploadfile5");

if ($filename eq "" )
{
copy("noimage.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/11111.png");
copy("noimagethumb1.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb11111.png");
goto SKIP5;
}

my $upload_filehandle = $query->upload("uploadfile5");
open ( UPLOADFILE, ">$result1/file.jpg" ) or die "failed to open '$upload_dir/1.jpg' $!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
copy("$result1/file.jpg","$result1/thumb1.jpg");
system("PhotoResize700x500ICO.exe $result1/file.jpg");
system("PhotoResize140x100ICO.exe $result1/thumb1.jpg");
move("$result1/file.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/11111.png");
move("$result1/thumb1.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb11111.png");


SKIP5:


$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$result1";

my $query = new CGI; my $filename = $query->param("uploadfile6");

if ($filename eq "" )
{
copy("noimage.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/111111.png");
copy("noimagethumb1.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb111111.png");
goto SKIP6;
}

my $upload_filehandle = $query->upload("uploadfile6");
open ( UPLOADFILE, ">$result1/file.jpg" ) or die "failed to open '$upload_dir/1.jpg' $!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
copy("$result1/file.jpg","$result1/thumb1.jpg");
system("PhotoResize700x500ICO.exe $result1/file.jpg");
system("PhotoResize140x100ICO.exe $result1/thumb1.jpg");
move("$result1/file.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/111111.png");
move("$result1/thumb1.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb111111.png");




SKIP6:


$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$result1";

my $query = new CGI; my $filename = $query->param("uploadfile7");

if ($filename eq "" )
{
copy("noimage.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/1111111.png");
copy("noimagethumb1.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb1111111.png");
goto SKIP7;
}

my $upload_filehandle = $query->upload("uploadfile7");
open ( UPLOADFILE, ">$result1/file.jpg" ) or die "failed to open '$upload_dir/1.jpg' $!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
copy("$result1/file.jpg","$result1/thumb1.jpg");
system("PhotoResize700x500ICO.exe $result1/file.jpg");
system("PhotoResize140x100ICO.exe $result1/thumb1.jpg");
move("$result1/file.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/1111111.png");
move("$result1/thumb1.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb1111111.png");


SKIP7:


$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "$result1";

my $query = new CGI; my $filename = $query->param("uploadfile8");

if ($filename eq "" )
{
copy("noimage.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/11111111.png");
copy("noimagethumb1.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb11111111.png");
goto SKIPend;
}

my $upload_filehandle = $query->upload("uploadfile8");
open ( UPLOADFILE, ">$result1/file.jpg" ) or die "failed to open '$upload_dir/1.jpg' $!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;
copy("$result1/file.jpg","$result1/thumb1.jpg");
system("PhotoResize700x500ICO.exe $result1/file.jpg");
system("PhotoResize140x100ICO.exe $result1/thumb1.jpg");
move("$result1/file.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/11111111.png");
move("$result1/thumb1.jpg","file.jpg");
system('roundimage.php');
move("file.png","C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/customers/$domainname/$result1/thumb11111111.png");






















SKIPend:


print "Content-type: text/html\n\n";
print "<html><head>\n";
print "</head>\n";
print "<body>";
print "<h1><center>$domainname</center></h1>";
print "<h1><center>SUCCESSFULLY CHANGED</center></h1>";

print "<h1><center><a href=\"http://www.$domainname.co.uk\">Back To Main Website</a></h1><br><br><br>\n\n";

print "<h1><center><a href=\"http://www.$domainname.co.uk/myadminpage.html\">Back To Admin Page</a></h1>\n";

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives