PHP function (file_exists) with mapped drive
Moderator: General Moderators
PHP function (file_exists) with mapped drive
I have been trying unsuccesfully to use php functions like file_exists with a folder that has been defined through apache alias. I can do a localhost/folder and see the contents of the folder, but I have not been able to make php see the folder. I must be missing something here. Any help?
Re: PHP function (file_exists) with mapped drive
Have you checked that ALL parts of the path are readable by apache?
ie
/path/path2/path3/file
All 3 folders must have execute (traverse) permission for apache and the file must have read permission for apache.
ie
/path/path2/path3/file
All 3 folders must have execute (traverse) permission for apache and the file must have read permission for apache.
Re: PHP function (file_exists) with mapped drive
Guess I am embarassed to say, I am not sure I know how to test that. I also failed to mention that this is being done in a windows environment.
Re: PHP function (file_exists) with mapped drive
Are you trying to use file_exists() on a relative path or an absolute one? When in doubt, always use absolute
Re: PHP function (file_exists) with mapped drive
I am using the following alias:
Alias /rofile/ "d:/rof/"
<Directory "d:/rof">
Options FollowSymLinks Indexes Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Then I am trying access a file as follows and create a link to the file:
$fp="rofile/1001.pdf";
if (file_exists($fp)) echo "<a href='".$fp."' target='new'>";
I have tried various combinations of slashes and no slashes.
I have also removed the if condition so the link appeared, when clicked, I get a 404 error. However when I go to 'localhost/rofile/', i see the files that are stored in the folder.
Alias /rofile/ "d:/rof/"
<Directory "d:/rof">
Options FollowSymLinks Indexes Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Then I am trying access a file as follows and create a link to the file:
$fp="rofile/1001.pdf";
if (file_exists($fp)) echo "<a href='".$fp."' target='new'>";
I have tried various combinations of slashes and no slashes.
I have also removed the if condition so the link appeared, when clicked, I get a 404 error. However when I go to 'localhost/rofile/', i see the files that are stored in the folder.
Re: PHP function (file_exists) with mapped drive
file_exists will require the file system path, not the url. ie d:/rof/filename.pdf
http://us2.php.net/manual/en/function.file-exists.php
http://us2.php.net/manual/en/function.file-exists.php
Re: PHP function (file_exists) with mapped drive
Alright then, problem solved! Thanks so much.. this is fabulous.
End result:
alias info as above
$fp="1001.pdf";
if (file_exists('d:/rof/'.$fp)) echo "<a href='http://ipaddy/rofile/".$fp."' target='new'>";
Again, thank you!
End result:
alias info as above
$fp="1001.pdf";
if (file_exists('d:/rof/'.$fp)) echo "<a href='http://ipaddy/rofile/".$fp."' target='new'>";
Again, thank you!