Hello. I was curious if anyone around here could help me write my own file uploading perl program. I know perl pretty well but can’t really find any literature to assist with creating my program. I want the file to be placed with a visitor comment on the page. My comments form and processor work great. I just need to learn the upload dynamics. Any help would be greatly appreciated. Thanks!
What are you having a problem with specifically? My guess is you’ll get more help if you post whatever you have so far and some specific problems you need help with.
I haven’t done this myself (I’d probably just adapt someone else’s script)… Google turns up some links with sample code that might be helpful, for example:
By the way, you should make sure to do a few things:
If the files are going to be able to be viewed / downloaded by the public, you should make sure that the files are sent in such a way that they aren’t rendered by the server. Otherwise, people can upload malicious CGI scripts and other junk, and could possibly execute them from a browser. I’ve seen people do this with various web-based file upload tools before. You probably want to disallow files with extensions like .php / .html / .cgi entirely, and make sure to put the files in a separate directory, possibly outside your web root.
Set some sane limits on file-size
Here is an example.
Perl / MySQL / HTML+CSS
Thanks for the replies guys, but I’ve seen the codes sent. I suppose I should have been more specific although I am currently trying to alter one of the recommended programs for use. I wanted my file upload to occur with my already created form by just adding another input field. 1) Can I actually do that and still process my form regularly by changing only the file value to binary mode? and 2) What are the exact mechanics behind extracting the file name? I figured from enough programs HOW to get them, but not exactly what goes on behind closed doors. As for the secuirty measures, I only allow up to 1MB file sizes, and only JPEG’s, GIF’s, and BMP’s are allowed past my form validation. = P If I can find the answer to my questions, i think I can manage soemthing. Thanks for the help though! d= D
You have not shown us the source to the script you are already using, so can’t help you there. I can tell you that the form will need to be multipart/form-data and the script will need to decode
The part containing the file field stores the filename in the Content-Disposition header.
Perl / MySQL / HTML+CSS
An alternative to a Perl upload is this Java upload at:
http://radinks.com/upload/ there is a free version, but it is worth paying for the Plus version. Also it can run a PHP file (script) after the upload, which allows you to do just about anything. IMOP