CGI.pm upload()

Discussion in 'Perl Misc' started by D Borland, Oct 11, 2003.

  1. D Borland

    D Borland Guest

    Hi Folks,

    Can anyone here tell me if there is a safe alternative to CGI.pm's upload
    function?

    There main reason for needing this is that i am needing to upload multiple
    files, (eg. image1, image2, image3, image4), but you can only pass the
    upload function an actual param not a $scalar value, so this means i have to
    specify each upload i will need and that means 4 times as much code, but
    most of all is that when it fails to upload the files, it's impossible to
    see what it failed on and why.

    Hope i explained that OK :)

    Thanks
     
    D Borland, Oct 11, 2003
    #1
    1. Advertising

  2. On Sat, 11 Oct 2003, D Borland wrote:

    > Can anyone here tell me if there is a safe alternative to CGI.pm's upload
    > function?


    In what sense do you consider CGI.pm unsafe?

    > There main reason for needing this is that i am needing to upload multiple
    > files, (eg. image1, image2, image3, image4), but you can only pass the
    > upload function an actual param not a $scalar value, so this means i have to
    > specify each upload i will need and that means 4 times as much code,


    I don't quite understand your point. The current documentation says:

    | You can have several file upload fields in the same form, and even
    | give them the same name if you like (in the latter case param() will
    | return a list of file names).

    > but most of all is that when it fails to upload the files, it's
    > impossible to see what it failed on and why.


    That's awfully vague. If you have a Perl problem, let's see some
    snippets of Perl here.

    If your problem is more about how to organise your CGI script to do
    what you want, rather than anything Perl-specific, you might be better
    placed on comp.infosystems.www.authoring.cgi (check its automoderation
    FAQ before posting).

    good luck.
     
    Alan J. Flavell, Oct 11, 2003
    #2
    1. Advertising

  3. On Sat, 11 Oct 2003, D Borland <> wrote:
    > Can anyone here tell me if there is a safe alternative to CGI.pm's upload
    > function?
    >
    > There main reason for needing this is that i am needing to upload multiple
    > files, (eg. image1, image2, image3, image4), but you can only pass the
    > upload function an actual param not a $scalar value, so this means i have to
    > specify each upload i will need and that means 4 times as much code, but
    > most of all is that when it fails to upload the files, it's impossible to
    > see what it failed on and why.


    The first thing a newbie needs to learn is how to include error checking
    in your code, so your script will be nice enough to tell you what is
    wrong. But that assumes that you tested it in a shell first to eliminate
    precompile errors (like missing ';' or mismatched quotes or brackets).

    You could download multiple files (like consecutively numbered names) with
    a loop (function method example).

    # assuming any 1 to 5 files w/field names image1..image5
    for $i (1..5) {
    my $upload;
    if ($upload = param('image'.$i)) {
    # Pull filename from end of any browser supplied path
    if ($upload =~ m|[/\\:]|) {
    $upload =~ m|[/\\:]+([^/\\:]+)$|;
    $upload = $1;
    }
    # add filename tests to assure compatible/non-conflicting name
    # like substitute underlines for spaces, etc.
    # do something useful with $upload
    }
    }

    --
    David Efflandt - All spam ignored http://www.de-srv.com/
     
    David Efflandt, Oct 11, 2003
    #3
  4. D Borland

    Anno Siegel Guest

    D Borland <> wrote in comp.lang.perl.misc:
    > Hi Folks,
    >
    > Can anyone here tell me if there is a safe alternative to CGI.pm's upload
    > function?
    >
    > There main reason for needing this is that i am needing to upload multiple
    > files, (eg. image1, image2, image3, image4), but you can only pass the
    > upload function an actual param not a $scalar value, so this means i have to
    > specify each upload i will need and that means 4 times as much code, but
    > most of all is that when it fails to upload the files, it's impossible to
    > see what it failed on and why.
    >
    > Hope i explained that OK :)


    It comes across a little breathless. A period or two would have helped.

    Anno
     
    Anno Siegel, Oct 13, 2003
    #4
    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. Kristian
    Replies:
    1
    Views:
    723
  2. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,457
    Bruce Barker
    Aug 3, 2005
  3. Heather Fraser
    Replies:
    0
    Views:
    638
    Heather Fraser
    Jul 5, 2004
  4. Replies:
    1
    Views:
    941
    Gabriel Genellina
    Nov 25, 2006
  5. Prakash
    Replies:
    3
    Views:
    465
    Ray at
    Nov 12, 2003
Loading...

Share This Page