Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Multiple file upload

by nysus (Parson)
on Jun 19, 2001 at 17:45 UTC ( [id://89747]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

nysus has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I'd like to make it easy for a user to upload a directory containing 10-30 files at one shot to a remote server. Can this be done with a standard browser? I know a multipart form with CGI.pm could be used but that would require the user to tediously select files individually. Is there a better Perl solution? Thanks.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot";
$nysus = $PM . $MCF;

Replies are listed 'Best First'.
Re: Multiple file upload
by dimmesdale (Friar) on Jun 19, 2001 at 17:50 UTC
    I admit that I don't do web programming too much, so there's probably(likely) a better solution. However, with that disclaimer behind us, what you *could* do is look up the NET::FTP module. It offers functions for you to copy whole directories over. (If you have the Perl Cookbook, its in there)
Re: Multiple file upload
by Eradicatore (Monk) on Jun 19, 2001 at 17:58 UTC
    I would try using expect. If for no other reason, just to add this amazing tool to your toolbox. Boiled down, it is a scripting language to automate programs that require user input. I.e. in this case ftp. You can write a *very* simple script that will upload just the files you want. I know someone that uses this to develop a whole website at home, and then just has expect scripts to tar everything up, upload it, untar, etc. etc.

    I know this may be a bit heretical, but hey, the right tool for the right job, right? I'm sure we all believe that, no matter how much some of us wish to believe perl is always the right tool for the right job. ;)

    Justin Eltoft

    "If at all god's gaze upon us falls, its with a mischievous grin, look at him" -- Dave Matthews

(Ovid) Re: Multiple file upload
by Ovid (Cardinal) on Jun 19, 2001 at 18:16 UTC

    If you're trying to do this through a CGI script, then no, there's no convenient solution. Multiple upload boxes are the way to go. The CGI protocol does not allow for any "mass upload" or "upload directory" methods and Perl itself is simply running on the server and doesn't affect the client. Perhaps your users can tar or zip the directory and just upload the result? That would be much simpler, if you can train them to do it.

    There might be a Javascript or Java solution, as these can run on the client side, there may be a way to do this. However, they are very restricted in what they can do for security reasons. No one wants malicious Javascript browsing through your files.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      If you can get your users to upload tar or zip files you could also have a checkbox indicate that the CGI script should uncompress it. Very minor scripting on the server side and an easy fix :) Although, dealing with users on this level is a bit painful.

      .....mental note to add this to my own site :) .....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://89747]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.