Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Upload Folders

by p6steve (Sexton)
on May 21, 2003 at 20:58 UTC ( #259886=perlquestion: print w/replies, xml ) Need Help??

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

Fine monks...

I try to upload a folder's worth of image files from a browser client, gen some thumbnails with Image Magick and publish to a web page. All working fine for a single jpeg.

Question can I get the user to specify a folder on the client in a browser form and then get CGI to upload all the (image) files on the client without having to specify one at a time...yawn???

Replies are listed 'Best First'.
Re: Upload Folders
by artist (Parson) on May 21, 2003 at 21:14 UTC
    You can zip all the file at the client side, do single file update, unzip at the server using Archive::Zip do your magic with Image::Magick and publish.

    An alternative way to use another protocols like FTP if possible or emails.

    Yet another alternative is to provide mutiple file upload boxes (like 10 at max), fill with the path (using javascript) to the folder and client may just have to type filename for the rest of the entries.

    Yet another alternative is to install a client software which can send the files to your server.

    artist be more precise...

      • Needs to be any client HTML browser
      • No explicit client sw install allowed
      • No (FTP) server on client available
      • Perhaps "inline" software <suck>javascript or java applet</suck> allowed

      I would much prefer a server side perl solution and I am wondering if there may be a clever way to fool browsers to send all files in a selected dir in a single multipart form (or to somehow iterate over the client files).

        If I had a browser that could be fooled into sending all the files in some directory, I'd stop using it.

        The Netscape upload hack is client-driven, not server-driven. The browser would have to support some scheme to send more than one file. Then you're into promoting a new standard.

        [ e d @ h a l l e y . c c ]

        Nothing to do with Perl, but if JavaScript is allowed, and the number and names of the files were predictable, it might be possible, right?

        I mean, if you knew that the files were always called "1.jpg" through to "30.jpg" then you could script the form values and the form submissions?

        It's still a bad idea, I'm just thinking aloud.

        “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
        M-J D
Re: Upload Folders
by cees (Curate) on May 21, 2003 at 21:17 UTC

    You can't upload a folder of images at one time. The file form element only accepts one file at a time...

    Some solutions to get around this include:

    • putting multiple file form elements on the upload page.
    • allowing the user to upload a ZIP file containing all the image files. On the server you can unzip the files using one of the Compress:: modules.
    • setup webDAV on the web server and allow them to upload images using WebDAV. I don't know if it is possible, but it would be very cool if you could hook into the WebDAV stuff in Apache using mod_perl to automatically filter the incoming files (generate your thumbnails as the upload happens). This might be possible with Apache2 and mod_perl2 using the new filter API, but I am not positive on that.


      So, wise masters, you say that instead of needing big hole in browser security, I just redefine problem.

      Real problem is that single file upload is - select file - wait 1 minute for thumbnail compression - select next file - sit 30 minutes getting bored.

      Best solution is have one page for multiple select, then go away have a Starkbier* and then all is done in background.

      *=approved form of sustainance for monks

        I'd say you need to separate uploading part from the processing part. You can force the client to use FTP to upload a bunch of files, and then process them all together.

        Leonid Mamtchenkov aka TVSET

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2022-05-23 23:38 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (82 votes). Check out past polls.