Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

reference a local file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

reference a local file

Postby holisticsam » Fri May 02, 2014 1:40 pm

I'm trying to reference a local file on my c drive. I don't know why I can't located it using the following php code.

"c:\\temp2\\temp.txt" or
"c:/temp2/temp.txt" or

if (file_exists("file///:c:\temp2\temp.txt")) {
echo "The file exists";
} else {
echo "The file does not exist - C:\\temp2\\temp.txt";
}
holisticsam
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Apr 24, 2013 10:55 am

Re: reference a local file

Postby seandisanti » Fri May 02, 2014 6:14 pm

Because apache doesn't have access to see outside of the webroot.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: reference a local file

Postby holisticsam » Sat May 03, 2014 9:04 am

I'm trying to code a webpage that will upload a file from a local c drive. Are you saying it cannot be done using php?
holisticsam
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Apr 24, 2013 10:55 am

Re: reference a local file

Postby seandisanti » Sat May 03, 2014 10:38 am

no, I'm saying that as far as apache is concerned, the local drive is not the entire c drive, it only sees what its given access to, which really should not be anything beyond the web root. There are other ways around it, like putting the file in some subfolder of the webroot if it's for web use, or have a task scheduler or cron job move it to where it can be read at set intervals. There are a lot of ways to accomplish what you want, what you should not do, however tempting it may seem, is give your apache access to your entire drive. Then you're just one good exploit away from SOL.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.