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: Intermediate:
fileupload status

 



stormin
Novice

Apr 21, 2002, 7:45 PM

Post #1 of 6 (1542 views)
fileupload status Can't Post

I working on a file upload script that will report the status back to the users browser. I am flushing the buffer. But, the browser does seem update. Eventual goal would be to have a popup status bar (file download in reverse). Any help would be appreciated.. Thanks

partial script below...


use File::stat;
use CGI qw/:push/;



$query = new CGI;

print $query->header(-nph=>1);

.

.

.

$|=1;

$sb = stat($filename);
$size =$sb->size;
print "Content-type: text/plain\n\n";


# Copy a binary file to somewhere safe

open (OUTFILE,">>/uploads/test.txt")|| die;

binmode (OUTFILE);

while ($bytesread=read($filename,$buffer,1024)) {
$bytestotal = $bytestotal + $bytesread;
if ($temp > $update){
print OUTFILE $buffer;
$percent = ($bytestotal/$size)*100;
$percent = sprintf("%2d",($percent));
print $percent ;
print " \n";

}

.

.


fashimpaur
User / Moderator

Apr 22, 2002, 11:35 AM

Post #2 of 6 (1536 views)
Re: [stromin] fileupload status [In reply to] Can't Post

Stromin,

Be advised that non parsed headers and CGI push are not supported in IE after version 3.0. So, this may not be a solution for you.

Good Luck,
Dennis

$a="c323745335d3221214b364d545".
"a362532582521254c3640504c3729".
"2f493759214b3635554c3040606a0",
print unpack"u*",pack "h*",$a,"\n\n";


yapp
User

Apr 25, 2002, 5:25 AM

Post #3 of 6 (1526 views)
Re: [fashimpaur] fileupload status [In reply to] Can't Post

I never got NPH working in the Microsoft IIS 5.0 server in Windows 2000.

Can anyone explain why? I'm also very interested in reporting an client-upload status to the browser

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


stormin
Novice

Apr 25, 2002, 8:18 PM

Post #4 of 6 (1523 views)
Re: [yapp] fileupload status [In reply to] Can't Post

for those who replied.. thanks. I figured out how to output midstream. If you would like examples, Please email me. There is a new delema. The problem is NOT dealing with browser output. The delema is.. when perl does the OPEN command... It actually does a file copy up to the web server to tmp location. Then the while routine takes over. So, I need to figure out is how to monitor the size of a random file that is created on the web server during the OPEN command. OR, figure out a different file handle command that does not create a tmp file first.


yapp
User

Apr 29, 2002, 1:33 AM

Post #5 of 6 (1518 views)
Re: [stromin] fileupload status [In reply to] Can't Post

hmmmm.

Since you use the CGI module, wouldn't you use that module too to upload the files? The CGI module has some nice methods for it.

Btw, doesn't the browser provide some HTTP header telling you what the file size for upload is? At least, you can use the CONTENT_LENGTH variable to see what the total post size is (including all other fields)

Oh, and could you please send me an example of you code at spam_yapp@hotpop.com?

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


stormin
Novice

Apr 29, 2002, 3:08 PM

Post #6 of 6 (1514 views)
Re: [yapp] fileupload status [In reply to] Can't Post

True on all cases.. But remember the goal is to monitor file being copied up. ie 10%, 20%.. 100% of total size

the way I see it.. and pretty much confirmed.. The issue is when the "open" command is stated (it might even be the q = new ->CGI ???), It creates a temporary file on the web server and copies the your file to the webserver to the temp file. Then the "while" routine in the first post kicks in.
you can monitor the tmpfile size with "stat" funcion, you can find out what the tmpfile is. What I can not do, is interrupt the process of the temp file copying to forward the tempfile name to routine to monitor its size.
My next attempt is going to happen tonight. I found out where CGI.pm creates the CGItemp### file. I am going to hardcode a name and location and launch my my monitor routine. (obviously this is going to create other issues)
Maybe I am making this harder than it should be. Either way, I would very open for any other ideas.

thanks again
neil

 
 


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

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