accessing files outside localhost

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ian Hird
Forum Newbie
Posts: 3
Joined: Tue Feb 15, 2011 7:33 am

accessing files outside localhost

Post 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
User avatar
ganesh_dabhade
Forum Newbie
Posts: 19
Joined: Sun Feb 06, 2011 12:42 am
Contact:

Re: accessing files outside localhost

Post by ganesh_dabhade »

Access the files with physical path.
Domsore
Forum Commoner
Posts: 46
Joined: Wed Jan 26, 2011 7:07 pm

Re: accessing files outside localhost

Post 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
Ian Hird
Forum Newbie
Posts: 3
Joined: Tue Feb 15, 2011 7:33 am

Re: accessing files outside localhost

Post 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
User avatar
ganesh_dabhade
Forum Newbie
Posts: 19
Joined: Sun Feb 06, 2011 12:42 am
Contact:

Re: accessing files outside localhost

Post 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.
Ian Hird
Forum Newbie
Posts: 3
Joined: Tue Feb 15, 2011 7:33 am

Re: accessing files outside localhost

Post 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
Post Reply