file_exists with symlink-ed files?
For our application we need to store files above the root so they can be accessed by the streaming media software.
I successfully created a symlink from:
/var/www/vhosts/myhost.com.au/httpdocs/fileserver/videostream/
to:
/usr/local/MediaServer/content/
and PHP will happily process my raw video following that symlink to the real file above the root.
开发者_Go百科However, if I try
file_exists('/var/www/vhosts/myhost.com.au/httpdocs/fileserver/videostream/myfile.mp4')
I run into all sort of "open_basedir restriction in effect" errors.
Is there a way around this? or do I need to just assume that if my database entries are correct and say the file was processed, that it actually was.
Would trying fopen work any better or is there still the basedir restrictions?
We are on a dedicated host with root permission so we can do whatever is needed.
Thanks.
Found a workaround, but it doesn't solve the question :-)
I can actually use CURL to pull in the headers of the actual file and this lets me know whether it exists or not. Plus an additional method is to check the existence of the Streaming Media servers custom URL for that file using CURL. Problem solved, but not quite how I wanted it to be.
You should look into is_link
instead of file_exists
If you just want to check if the link exists (and not that the link target exists to which you have no access anyway because of the basedir restrictions) you could use the readlink function instead of file_exists
. If it returns a string then the link exists, if it returns false
then the link most likely does not exist.
if (@readlink($filename) !== false)
{
echo "Yay!";
}
In theory the basedir restrictions shouldn't trigger here, but I don't know for sure.
精彩评论