Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

CGI: Browse for directory (not file)

by Anonymous Monk
on Nov 20, 2004 at 23:04 UTC ( [id://409294]=perlquestion: print w/replies, xml ) Need Help??

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

How do I use a CGI <FORM> tag to browse for a Directory (not a file)?

To upload a file in a multipart form I do something like:
<INPUT TYPE="FILE" NAME="file">
Is there some equivalent for a directory?
e.g. <INPUT TYPE="DIRECTORY" NAME="getdirname">

Is there a way to do this with CGI.pm?

Thank you.

Replies are listed 'Best First'.
Re: CGI: Browse for directory (not file)
by steves (Curate) on Nov 20, 2004 at 23:20 UTC

    You're confused about who does what. The browser interprets the <INPUT TYPE="FILE" NAME="file"> and presents the file browser dialog box to the user. When the form is submitted by the browser, the CGI program gets the file data provided by the browser.

    I am not aware of any browser that supports directory uploads. Some will allow more than one <INPUT TYPE="FILE" NAME="file"> tag per page, which might offer the ability to let someone pick several files. But I've never tried that and I've read it's browser dependent.

    If you want to automate the uploading of a full directory of files to an existing browser page/CGI that supports one file per transaction, you could automate that with Perl and LWP.

Re: CGI: Browse for directory (not file)
by TedPride (Priest) on Nov 21, 2004 at 11:03 UTC
    You could theoretically zip or tar or whatever your directory and then have your script check file type and unpack the directory on the other end.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://409294]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-19 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found