Perl: the Markov chain saw | |
PerlMonks |
Re: File Uploadingby khkramer (Scribe) |
on Jan 02, 2002 at 04:41 UTC ( [id://135582]=note: print w/replies, xml ) | Need Help?? |
As grep notes, asking how to securely store your files opens up a big can of worms. You can certainly store multi-megabyte chunks of information in mysql, but that's not really the issue. Mysql isn't a way to store things securely anymore than the filesystem is. You probably want to think (read/learn) some about encryption and security in general. As for file uploads, the Apache::Request module is great. Here's a bit of simple code to handle file uploads in a mod_perl context. You'll need to do a little Apache configuration to hook a url to the UploadDemo handler sub, of course. Something like:
Or, if you're doing this in Mason or some other templating environment, you can strip this code down even a little further, to get the hang of things. I usually prototype this kind of standalone thing in Mason, then flesh it out as a mod_perl module when I'm happy with the logic. Note that slurping the whole thing into a single scalar will be more memory-intensive than looping over the filehandle a line at a time. The Apache::Request documentation gives more examples and details (including describing a nifty UPLOAD_HOOK that can be defined to -- among other things -- display a progress meter as the file is read in.) Kwin
In Section
Seekers of Perl Wisdom
|
|