Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 ? - Answer 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 cooling their heels in the Monastery: (7)
As of 2016-08-25 16:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (361 votes). Check out past polls.