file size OT

J

Jeff Thies

I have a "demand" for a file upload progress bar.

I've figured out how to return the number of bytes uploaded/saved back to
the browser. What I haven't figured out is how to read the file's size,
either client or server side (perl), so I can calculate a percentage.

I would have thought this was embedded in the file somewhere, as well as
it's content type. I can't find it, do I have this wrong?

I'm terribly sorry for asking this question here, I'm a bit desperate for
an answer and I know someone here knows the answer. I haven't found it
elsewhere.

Jeff
 
J

Joe Smith

Jeff said:
I've figured out how to return the number of bytes uploaded/saved back to
the browser. What I haven't figured out is how to read the file's size,
either client or server side (perl), so I can calculate a percentage.

The size of the file on the server is
$size = -s $file;

The size of the file on the client is not available.
With a multi-file POST, the Content-length does not give any indication
as to the current file's size.

Upload progress bars should be implemented on the client's browser,
not the server.
-Joe
 
J

Jeff Thies

I've figured out how to return the number of bytes uploaded/saved back
to
The size of the file on the server is
$size = -s $file;

That looks like the file size is not available until after the file has been
saved.
Is that right?

Jeff
 
J

Joe Smith

Jeff said:
That looks like the file size is not available until after the file has been
saved.
Is that right?

Depends on the OS and the module used for uploads.

Unix-like OSes let you see the size of the file while it is being
written, others show zero bytes until the file is closed.
CGI.pm provides access to the file after it has been completely
uploaded; for do-it-yourself solutions you can count the number
of decoded bytes that you are writing to the file.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,184
Latest member
ZNOChrista

Latest Threads

Top