Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to check the size of each files that are being uploaded

0 views
Skip to first unread message

towe...@gmail.com

unread,
Sep 3, 2008, 3:45:46 AM9/3/08
to
Hello.
I am developing cgi perl script for uploading files with uploading
progress bar.
Now i have script that do this good.
While uploading i must to know total size of the file that is being
uploaded.
It is not problem becouse there is global variable
$ENV{CONTENT_LENGTH} that contains the lenght of the attachment.

The problem is when 2 or more files are bieng uploaded.

How can i know the size of each file?
I use CGI->new(\&hook) method to catch file uploading process.

xho...@gmail.com

unread,
Sep 3, 2008, 11:56:18 AM9/3/08
to
"towe...@gmail.com" <towe...@gmail.com> wrote:
> Hello.
> I am developing cgi perl script for uploading files with uploading
> progress bar.
> Now i have script that do this good.

How does it work? Does it use a separate frame for the monitoring?

> While uploading i must to know total size of the file that is being
> uploaded.
> It is not problem becouse there is global variable
> $ENV{CONTENT_LENGTH} that contains the lenght of the attachment.
>
> The problem is when 2 or more files are bieng uploaded.
>
> How can i know the size of each file?

Strictly on the server, you can't. At least not until each file is done
being sucked down by the server and the next "multipart/form-data" starts
arriving.

You might be able to craft some javascript running on the client side that
will check on the local file size and encoded it into the form submission.

But I don't see the point. As a user, I'd want to know when the upload is
likely to be done. What do I gain by knowing what each individual
component is doing?

> I use CGI->new(\&hook) method to catch file uploading process.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Petr Vileta (fidokomik)

unread,
Sep 3, 2008, 7:17:49 PM9/3/08
to
Partial solution is to use javascript to check file sizes before user click on
Send button. But be sure to warn users which have javascript disabled in
browser. It is very simple:

<body>
<noscript>
<div style="border: 2px solid red">You have not javascript enabled, please
enable it.</div>
</noscript>
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>


-- Posted on news://freenews.netfront.net - Complaints to ne...@netfront.net --

towe...@gmail.com

unread,
Sep 4, 2008, 3:21:35 AM9/4/08
to
> Partial solution is to use javascript to check file sizes before user click on
> Send button. But be sure to warn users which have javascript disabled in
> browser. It is very simple:
>
> <body>
> <noscript>
> <div style="border: 2px solid red">You have not javascript enabled, please
> enable it.</div>
> </noscript>
> --
I tried to get file size with javascrip but i found that it is
imposiblem. Browsers don't allow this operation.
Do you know how to do this?

Petr Vileta (fidokomik)

unread,
Sep 4, 2008, 8:59:47 PM9/4/08
to
I did not test it but I found something
http://www.jguru.com/faq/view.jsp?EID=330134
http://forums.digitalpoint.com/showthread.php?t=137411
http://bytes.com/forum/thread460516.html

The magic words for Google are "get file size javascript" :-)
Maybe some of that can help you.

0 new messages