problem function length

J

john.swilting

I recover a file via a form
my $attachement = $cgi->param('attachement');

then
my $oct_long = eval { do {use bytes;length $attachement;};};

and I find myself with the length of characters of the way of the file
whereas I would like to calculate the size of the file
 
J

john.swilting

john.swilting said:
I recover a file via a form
my $attachement = $cgi->param('attachement');

then
my $oct_long = eval { do {use bytes;length $attachement;};};

and I find myself with the length of characters of the way of the file
whereas I would like to calculate the size of the file

how to make
 
X

xhoster

john.swilting said:
I recover a file via a form
my $attachement = $cgi->param('attachement');

then
my $oct_long = eval { do {use bytes;length $attachement;};};

and I find myself with the length of characters of the way of the file
whereas I would like to calculate the size of the file

Do you mean "name of the file" rather than "way of the file"? Is so, that
is exactly what I would expect to happen.

You probably want to us ->upload, not ->param. And then you can either use
"-s" on the filehandle (haven't tried it), or just read it and count its
size.


Xho
 
G

Gunnar Hjalmarsson

Michele said:
Since you seem to be using CGI.pm, you find everything explained
quite clearly in its docs under the "CREATING A FILE UPLOAD FIELD"
heading.

"Quite clearly"? I believe there is a reason why people often encounter
difficulties when uploading files. That's why I wrote CGI::UploadEasy.
 
J

John Bokma

Purl Gurl said:
I agree. Use of Stein's module is amongst the worst of
programming mistakes. His module is buggy, unyielding
and unforgiving.

Feel free to write a better CGI related module.
Reading documentation for CGI.pm is
as easy as reading Chinese instructions for assembly
of a child's bicycle;

Yes, quite some modules on CPAN suffer from this. Or documentation in
general. You can help by annotating the documentation, or sending a patch
to the author(s) of the module with better documentation, or write a howto
/ tutorial and publish it on your / a site.

Bitching about it here doesn't help much. Most people are aware of the
lack of quality documentation has in general. Following any of the three
above suggestions /does/ help however.
 
G

Gunnar Hjalmarsson

Purl said:
I agree. Use of Stein's module is amongst the worst of
programming mistakes.

CGI::UploadEasy is just a wrapper around CGI.pm and makes heavy use of
"Stein's module".
 
G

Gunnar Hjalmarsson

Michele said:
Well, it doesn't seem too difficult to me:

: When the form is processed, you can retrieve the entered filename by
: calling param():
:
: $filename = param('uploaded_file');
:
: Different browsers will return slightly different things for the name.
: Some browsers return the filename only. Others return the full path to
: the file, using the path conventions of the user's machine.
: Regardless, the name returned is always the name of the file on the
: *user's* machine, and is unrelated to the name of the temporary file
: that CGI.pm creates during upload spooling (see below).
:
: The filename returned is also a file handle. You can read the contents
: of the file using standard Perl file reading calls:

Right after that, the CGI.pm POD talks about problems with the just
described method, and recommends that the upload method is used instead.
It can be read and understood, but it's not very straightforward.

And people encounter difficulties over and over.
 

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

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,661
Latest member
sxarexu

Latest Threads

Top