CGI: how to test existence of file to upload?

J

J Krugman

I'm using CGI.pm to write a CGI form. This form includes a filefield.
How can I test if the file entered by the user actually exists?

(I tried using "defined fileno $q->param('filename')", but it
returns true whether or not the file 'filename' exists.)

TIA,

-Jill
 
T

The Sender

At some time in the past J Krugman wrote :
I'm using CGI.pm to write a CGI form. This form includes a filefield.
How can I test if the file entered by the user actually exists?

(I tried using "defined fileno $q->param('filename')", but it
returns true whether or not the file 'filename' exists.)

TIA,

-Jill

Hi Jill,

You can't since you don't have file access to the Client's Machine. You'll
just have to rely on them I'm afraid not to tell porkies.
 
A

Alan J. Flavell

I'm using CGI.pm to write a CGI form. This form includes a filefield.
How can I test if the file entered by the user actually exists?

What is it that you think you need to know? If they upload some data
by that means, you'll get it. If they don't, you won't.
(I tried using "defined fileno $q->param('filename')", but it
returns true whether or not the file 'filename' exists.)

Are you confused about where this file actually sits?

They specify a file on their computer. The form submission uploads it
to your server. You're wasting your time looking for _their_ actual
file on _your_ computer. You just get the data (and usually an
indication of what the local file had been called on their machine).

This has nothing specific to do with Perl: it would be the same
principle in any server-side CGI script, no matter what language.
 

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,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top