Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Perl Monk, Perl Meditation
 
PerlMonks  

Answer: how can i upload a file using a web-browser and the chmod() the file ?

( #34214=categorized answer: print w/ replies, xml ) Need Help??

Q&A > HTTP and FTP clients > how can i upload a file using a web-browser and the chmod() the file ? contributed by merlyn

File uploading is fairly painless with CGI.pm. From the manpage:
CREATING A FILE UPLOAD FIELD print $query->filefield(-name=>'uploaded_file', -default=>'starting value', -size=>50, -maxlength=>80); -or- print $query->filefield('uploaded_file','starting value',50 +,80); [...] When the form is processed, you can retrieve the entered filename by calling param(): $filename = $query->param('uploaded_file'); [...]
You can then copy the file to the appropriate place (perhaps using the File::Copy core module), and then use the chmod operator to make it executable.

An important security concern is to make sure your script is not available to the general populus, because you've effectively given an open prompt to whomever wants it.

Comment on Answer: how can i upload a file using a web-browser and the chmod() the file ?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-04-20 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls