Gossamer Forum
Home : General : Perl Programming :

newbie question

Quote Reply
newbie question
Hello, I just started learning CGI and I was wondering. Is it possible to access a file that is in a folder higher than your webserver default folder.

For example my apache webserver starts at /home/www/htdocs which is also routed to /home/users/me/est/share.

what if I want to get a non text file say a powerpoint which is located in my est folder without using virtualhost since other systems are also using the server

thanks so much
Quote Reply
Re: [wired_lain] newbie question In reply to
Unless your server has a major security hole, then I very much doubt it Tongue You should only have access to files that you can access via FTP (or Telnet/SSH if you have it)... Wink

If you managed to upload the file to that folder, the chances are you can get it though. When grabbing the file, just use something like;

open(FILE, "/path/to/file.txt") || die "Cant get it: $!";

rather than just the ralative file, something like;

open(FILE, "file.txt") || die "Cant get it: $!";

Hope I understood you correctly Tongue

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] newbie question In reply to
Quote:
Unless your server has a major security hole, then I very much doubt it You should only have access to files that you can access via FTP (or Telnet/SSH if you have it)...

That's garbage. You have read access to thousands of files on a server. As long as the file exists or you can at least get it put where you want then you can read the file as long as you have read access to it.
Quote Reply
Re: [Paul] newbie question In reply to
I can access the file if its a text file through command open cause my root can go as far back as that but my text files have data files like powerpoint or excel files in the same folder. I have a code wherein i can open a text file and print it to an html also included is a link to the appended file

my file directory is in /home/users/me/est

my http server goes to /home/www/htdocs which is the same place as my /home/users/me/est/share

so i cant put a <a href=something.ppt> in my file cause it returns

http://myserver/something.ppt which of course cant be found.

is there a way i can point to that file which is in my est folder?
Quote Reply
Re: [wired_lain] newbie question In reply to
You need to use open() and read() then print the file directly to the browser after printing a powerpoint header.

print "Content-type: application/vnd.ms-powerpoint\n\n";
Quote Reply
Re: [Paul] newbie question In reply to
I"m sorry to sound so stupid but could you elaborate on that how do I open and read the file? how c an I make it clickable by the browser?

do I just use open(file, $thefile) then print with the header? what if its another type like pdf? do I write if statements?

thank you very much
Quote Reply
Re: [wired_lain] newbie question In reply to
I figured out how to do the open the powerpoint file

now jsut the second question please if there are different sets of data like powerpoint , pdf, images, do I just do if else statements?
Quote Reply
Re: [wired_lain] newbie question In reply to
I figured out how to do it, but its kinda lengthy and simple hehe with al the if else but there are only a number of types that is uploaded so i just declared all of them