×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Progress Bar

Progress Bar

Progress Bar

(OP)
I am trying to make sense of CGI::ProgressBar and tk::ProgressBar.
I have found a few partial examples but the explanations just go right over my head.
I require a progress bar in an existing file upload routine, what are my best options?
Do the tk modules work with a standard installation of Perl?

Keith
www.studiosoft.co.uk

RE: Progress Bar

(OP)
The required process appears to be simple and probably is.
I have a loop which uploads 1024 byte chunks of data to a server.
How hard can it be to update a jquery script after every chunk is uploaded?
Suggestions please of how this can be achieved.

Keith
www.studiosoft.co.uk

RE: Progress Bar

(OP)
I have tracked down a basic uploader and progress bar but I have encountered an odd problem.

The following code snippet is invoked from a HTML form containing an input type='file' field.
The first line of code runs the sub routine but there is a delay of over 30 seconds before the sub routine is called when loading a 3Mb file.

CODE

my $q = new CGI (\&hook);

sub hook {
print "Hook<br>"; 

Is there an obvious reason for this behaviour?

Keith
www.studiosoft.co.uk

RE: Progress Bar

I believe CGI needs a hook to report the progress via the temp file it uses during upload. It's been a while since I looked at this and in the end I decided to move to HTML5 instead.

Is there a reason you cannot use HTML5 for this? It is so much nicer and easier!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Progress Bar

(OP)
Thanks for the reply.
I am just revisiting an old problem because some of the users need to upload 8Mb files and many of them are using older browsers without HTML5 support.

The delay is occurring before the upload actually starts and seems to be linked with the <input type='file' command.
I am wondering what actually happens as it appears to do something with the file ID before the script is processed.

Keith
www.studiosoft.co.uk

RE: Progress Bar

It may be possible to shim/polyfill the missing HTML5 behavior, it was rather flaky and I had a lot of issues with Webshim when I tried to support IE9 with it and eventually gave up, but they may have fixed it by now?

Alternatively can they run Flash?

I use this for my music site uploads currently before I port to HTML5, and it works very well uploading 100mb+ files no problem!

http://www.uploadify.com/about/

Though I must admit the provider seems to have gone a bit sucky as it appears the new version for HTML5 is no longer free and the free version is Flash only with no HTML5 support / Flash fallback.

If you want I can send you the older version that was HTML5 with Flash fallback, see my sig and pop me an email!

All my solutions use a client side progress mechanism with Perl back-end file upload script, I gave up trying to work out the weirdness of CGI, file uploads and the progress hook!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Progress Bar

(OP)
The actual upload works fine and I have introduced a CSS driven progress bar which works very well except for the delay in starting.
It is possible that this delay has always been present but has not been noticeable when uploading small files.
The user selects the file in the normal way, clicks upload and then there is a delay of 30 seconds or so.
After that the upload starts and the progress bar reflects the percentage uploaded until completion.
The length of start delay appears to reflect the size of the file so the key is there somewhere.

I have avoided Flash for quite a while now as it's use upsets the mobile users.

The internet seems to be awash with incompatible technologies making a developer's life a bit of a functional lottery.

Keith
www.studiosoft.co.uk

RE: Progress Bar

Hmm, how do you get CSS to display feedback from the progress of the upload, that intrigues me!

Is it possible that the file is uploaded first via CGI and then the feedback / progress reports retrospectively.

So you don't actually have a real-time upload mechanism and possibly the upload is taking twice as long as it should, firstly to upload the file, then secondly to pretend it's uploading and do the progress thing?

Quote:

The internet seems to be awash with incompatible technologies making a developer's life a bit of a functional lottery.
Yup, I have used an all Perl / PHP tool before: http://uber-uploader.sourceforge.net/ , so this might help.

I spent many years trying different solutions before HTML5, since HTML5 I have ditched anything < HTML5 and only support those browsers that have

CODE

window.FileReader 
window.FormData 
'upload' in ($.ajaxSettings.xhr()) 
Now coding form submissions and file uploads with a progress GUI is so simple. The client side doing all the work and it matters not what back-end is actually receiving the data.

I know not very PC, but as my users are in Financial Services, they should not be running OSes that are not patched / supported, so XP is out of the picture, all the software providers in the industry only put out Windows compatible software so mobiles / Apple is out the picture also, leaving only Vista+ / IE10+ or any of the other free browsers that all support the new HTML5 stuff. Has made my life so much easier!

Plus our members' extra-net is cross browser compatible (Perl/JQuery/HTML5/CSS3/IIS7), and works in browsers running on Linux / Windows, the only thing I cannot test is Safari as I don't have a Mac, but as there is Firefox for Mac's, it's all good smile






"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Progress Bar

(OP)
The delay occurs before the upload routine is even started.

I am using the simplest of HTML/Perl to test it.
Try uploading an 8Mb image and see how long the script takes to run.

CODE --> html

<!DOCTYPE html>
<html>
<head>
<title>Upload Test</title>
</head>
<body>
<h1>File Upload Test</h1>
<FORM METHOD="POST" ACTION="cgi-bin/test2.pl" ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="FILEID" VALUE="" SIZE=50 MAXLENGTH=80><BR>
<INPUT TYPE="hidden" NAME="call" VALUE="uploadimage">
<INPUT TYPE="submit" NAME="submit" VALUE="Upload File To Server"></FORM>
</body>
</html> 

CODE --> Perl

#!/usr/bin/perl
use strict;
use warnings;
print "Content-Type: text/html\n\n";
print "This simple script only displays this text and performs no other function."; 

Keith
www.studiosoft.co.uk

RE: Progress Bar

(OP)
I assume you mean that it took 5 secs for the text to appear.
The connection speed is quite slow here so I can only think that has something to do with the difference.
It appears to load the file before the upload starts as I can see transfer activity on the router, if that is the case, where does it upload it to?

Keith
www.studiosoft.co.uk

RE: Progress Bar

Quote:

I assume you mean that it took 5 secs for the text to appear.
Yes.

We have a 40mb/40mb fibre lease line so uploads as pretty nifty.

Quote:

It appears to load the file before the upload starts as I can see transfer activity on the router, if that is the case, where does it upload it to?

The browser shouldn't be caching / loading it anywhere first that I'm aware of, it simply reads the file from the UNC location.

Is it perhaps a setting on the web server? Are you running (LAMP), could a modperl configuration or other config be causing this behavior?

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Progress Bar

(OP)
Your questions are the same I have been asking but nobody seems to have a definitive answer.
My ISP are saying that they don't see much of a delay either but that is not surprising as they do have a very fast connection.
When I say ours is slow, it is currently 6-8Mb so although it is slow by modern standards, a 3Mb file should be processed in much less than 30 seconds.

Keith
www.studiosoft.co.uk

RE: Progress Bar

(OP)
That is the conclusion I have arrived at but is this behaviour something which can be set up on a server?

Keith
www.studiosoft.co.uk

RE: Progress Bar

Out of my knowledge-base, I use Catalyst MVC framework for all my Perl stuff now and it takes the request and packages it up in an easy to use object, I've not suffered from this phenomenon.

If the server has mod_perl installed it might be related to the Apache request setup, could it be taking the request then handing it over to your script so in theory processing it twice?

http://www.informit.com/articles/article.aspx?p=27...

What's your environment?

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Progress Bar

(OP)
I use Perl a lot and this is the first real illogical issue I have had with it.
There have been many things I have had to learn but this issue defies all reason and like you I believe that the file is being loaded before control is handed to the script.

My ISP are struggling to understand the actual problem and their most recent contribution was telling me that the HTML file which calls the uploading script loads in under a second - not sure what relevance that has and until they actually understand the problem, I feel a solution could be a long time coming.

Perl 5.8.8 is installed on the shared hosting server.

Keith
www.studiosoft.co.uk

RE: Progress Bar

(OP)
It is on Linux and I don't think Mod_Perl is installed, although it could be for all I know.
If I can get them to understand the actual problem - I think that would go a long way towards solving it.

Keith
www.studiosoft.co.uk

RE: Progress Bar

(OP)
It would appear that the file is cached into the server's memory before being saved to the server itself.
Upload times are comparable to the time taken to FTP the same files.

The whole point of this exercise was to add a progress bar to an existing website to keep the visitor informed about upload progress.
As it doesn't work reliably, there is no point in having it so I have replaced it with an animated gif.

Keith
www.studiosoft.co.uk

RE: Progress Bar

Hi Keith,

As we concluded something somewhere was processing the file before it was being given to your script.

Why have they configured the server in this fashion? Yes, memory is used to cache the file, but I though it was read and written in chunks, surely you cannot afford to read a 500MB file from multiple users all into memory in its entirety before writing any of it to disk?

As you have found, you cannot utilise the chunks read/write hook of CGI if the entire file is uploaded before your script even gets a sniff at it.

I guess an animation on submit of the upload is a compromise.




"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Progress Bar

(OP)
The animation is a compromise but I would prefer a real time progress bar.

I tried the same scenario on another server and got he same results.
I am wondering if this is actually the default behaviour of shared servers but if it is, uploading large files could crash the server.

Keith
www.studiosoft.co.uk

RE: Progress Bar

That's what I was thinking, you don't want any one user on a web-server sucking up large chunks of memory.

Though I still don't get why the upload is taking so long, even if it is caching the file first, 30+ seconds seems a long time for an 8MB file.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Progress Bar

(OP)
I thought that one of the experts would have put an end to our amateur speculation by now but unfortunately not.
While the animation does the job, I did have in mind a rather fancy and unusual progress graphic but if the basic chunk reporting doesn't work it would look a bit silly.
I have posted the question in HTML as it seems to be more of a HTML issue than a Perl one.

Keith
www.studiosoft.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close