CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
saving files in Unix



Jul 19, 2000, 9:25 AM

Post #1 of 4 (780 views)
saving files in Unix Can't Post

I am working on a form that generates an HTML file. I want to be able to give users the ability to specify (via the form) where they want to save the file (relative or absolute) and under what name to file is saved. How can I dynamically save these files based on the user's input?

Thanks in advance,


Jul 19, 2000, 6:16 PM

Post #2 of 4 (780 views)
Re: saving files in Unix [In reply to] Can't Post

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

open (FILE, ">$path");
print FILE "$stuff";
Where $path contains the path to the file and $stuff contains the stuff you want to print into the file.


Jul 20, 2000, 4:02 AM

Post #3 of 4 (780 views)
Re: saving files in Unix [In reply to] Can't Post

OK, I guess I was not clear enough in what I am looking for. I want to have a user fill out a form, and then have a perl script that will dynamically create an HTML file based on the way the user fills out the form. 2 things that the user will have to provide when filling out the form are a file name under which the file will be saved, and a path to where the file will be saved. I want the user to be able to specify where the file will be saved, and what the file will be named.

Thanks again,


Jul 20, 2000, 7:33 AM

Post #4 of 4 (780 views)
Re: saving files in Unix [In reply to] Can't Post

Assuming Cretep's code and that you're using ...

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

$path = param('path') . "/" . param('file');</pre><HR></BLOCKQUOTE>

Error checking and sesnisble defaults are left as an exercise to you. :-)

On a side note, what you're doing has huge security implications: what if someone chooses the same path and filename as the script itself? Ooops! I hope you have backups!


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives