Reputation: 1053
I'm trying to navigate to C drive via PHP on my local drive, this one line of code works fine:
<a href='<?php echo'file:///C:\Users\Emily\Documents\'?>' TARGET="_blank" >Clcik Me</a>
This works fine from my local drive but as soon as this is on my sever it throws an error. I've been trying to strip and replace slashes but to no luck, hope sone one can help me.
Upvotes: 0
Views: 1472
Reputation: 1010
This is because on the server there is no "C:\Users\Emily\Documents".
You need to make sure that the filepath you use is available to you on the server. My recommendation would be to setup your local machine to have the same filepath which exists on your server.
For example lets say you have a folder named Web, in which you keep the following files and folders:
index.php
\images (This is another folder)
From your file if you wanted to access a file in the images folder, from your index.php file you would access it as "images\FileYouWant.jpg"
Your server should have the same setup so you copy index.php and the images folder into the folder on your server, this way they keep the same file paths.
You can find more on file paths here
Upvotes: 2
Reputation: 1700
Your server OS maybe not windows and file path is different!
Try to debug with <?php var_dump(real_path('file_path.php')); ?>
Upvotes: 0
Reputation: 7183
you can't access local file links from remote servers. if that were still possible (Like it was many years ago), a remote site could get at your local files...
Upvotes: 1