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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Setting an explicit Path and using optional variable

 



steveJ
Deleted

Mar 4, 2000, 8:46 PM

Post #1 of 3 (598 views)
Setting an explicit Path and using optional variable Can't Post

Hi Gang, this one should be easy for most of you.

I want to assign a specific directory that is to be used for storing, and creating files, but I also want to use a variable for designating what the filename is going to be.

Example c:\directory\subdirectory

MyVariable = "mytextfile.txt"

So I would end up with something like
c:\directory\subdirectory\mytextfile.txt in which I open or create if not found.

The script I have been messing with allows me to pass a filename at the end. But since I dont know how to set an explicit path to append this to, one can literally create a file anywhere by doing something like:
http://myweb/cgi-bin/script.pl?c:\123.txt

This opens up a big security hole in itself.

I'm sure this is a one line fix, I just can't seem to get it right Wink

Thanks



darian
Deleted

Mar 5, 2000, 2:31 PM

Post #2 of 3 (598 views)
Re: Setting an explicit Path and using optional variable [In reply to] Can't Post

I would try something like this:

$basepath = '/path/to/mydir';
$file = $q->param('file');
$usefile = "$basepath/$file";

now something like this:
http://mydomain.com/cgi-bin/myprog.cgi?mytext.txt

will be /path/to/mydir/mytext.txt


steveJ
Deleted

Mar 6, 2000, 7:41 PM

Post #3 of 3 (598 views)
Re: Setting an explicit Path and using optional variable [In reply to] Can't Post

Thanks Darian, I will try this tomorrow and see if it works, I'll let ya know


 
 


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

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