Page 1 of 1
accessing files outside localhost
Posted: Tue Feb 15, 2011 7:46 am
by Ian Hird
I have some files that I want to access from a script that is running on my C drive in localhost. I have tried using ../ in front of the file name to go up a directory level but the php code seems to prefix everything with
http://localhost.
I am using XAMPP 1.7.3! for Windows, Apache 2.2.14 and PHP 5.3.1
Some advice would be most appreciated.
Ian
Re: accessing files outside localhost
Posted: Tue Feb 15, 2011 8:28 am
by ganesh_dabhade
Access the files with physical path.
Re: accessing files outside localhost
Posted: Tue Feb 15, 2011 8:29 am
by Domsore
But if you take this to an online server, you wont be able to access you hard disk from there. Just a thing to remember
Dom
Re: accessing files outside localhost
Posted: Tue Feb 15, 2011 8:54 am
by Ian Hird
ganesh_dabhade wrote:Access the files with physical path.
Thanks for the reply Ganesh but I tried to do that.
I set up a variable of $image = "C:/etc" and tried to displat the file with <img width='950' src='$image' /> but the code generated
http://localhost/C:/etc
Any other ideas or have I done something silly in my code?
Ian
Re: accessing files outside localhost
Posted: Tue Feb 15, 2011 9:06 am
by ganesh_dabhade
try to use file protocol
file:///c:/etc instead of c:/etc
You won't be able to access files on server. You have to change ur scripting policy.
Post the thing u want to do, I'll try my best.
Re: accessing files outside localhost
Posted: Tue Feb 22, 2011 10:59 am
by Ian Hird
ganesh_dabhade wrote:try to use file protocol
file:///c:/etc instead of c:/etc
You won't be able to access files on server. You have to change ur scripting policy.
Post the thing u want to do, I'll try my best.
Thanks Ganesh but I have had the following reply from Larry Ullman so I will have to move the file into local host:-
'You can't access them directly. A Web server can only provide documents found within the Web directory. To accomplish what you're trying to do you'll need to use a proxy script. I'm pretty sure the book has an example of one, and I also just wrote about this in a recent newsletter (see the main site pages for that).'
Thanks once again
Ian