CGI: how to test existence of file to upload?

Discussion in 'Perl Misc' started by J Krugman, Jul 8, 2003.

  1. J Krugman

    J Krugman Guest

    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
    J Krugman, Jul 8, 2003
    #1
    1. Advertising

  2. J Krugman

    The Sender Guest

    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.

    --
    Regards,

    William
    The Sender, Jul 8, 2003
    #2
    1. Advertising

  3. On Tue, Jul 8, J Krugman inscribed on the eternal scroll:

    > 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.
    Alan J. Flavell, Jul 8, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bjam
    Replies:
    0
    Views:
    390
  2. Matt
    Replies:
    14
    Views:
    2,269
    Rolf Magnus
    Feb 22, 2005
  3. Thierry S.

    Test the existence of a variable?

    Thierry S., Sep 3, 2004, in forum: Python
    Replies:
    5
    Views:
    2,585
    Dan Gass
    Sep 3, 2004
  4. Replies:
    9
    Views:
    4,776
    Ancient_Hacker
    Oct 26, 2006
  5. zino

    how to test cache existence

    zino, Jan 23, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    577
    Alvin Bruney [ASP.NET MVP]
    Jan 24, 2008
Loading...

Share This Page