Welcome Guest, Not a member yet? Register   Sign In
problems with file_exists()
#1

[eluser]Piatra[/eluser]
im having some trouble with the function file_exists(). it returns false even though the file exists eg.
Code:
if(file_exists($file)) echo "<img >"
wouldnt echo anything, but if i copy paste the url in the address bar it works. is it my coding ? i did use the base_url() function to make sure the path is always correct.
#2

[eluser]Mike DeFelice[/eluser]
I believe file_exists needs to use the relative path on the hard drive. For instance file_exists('./images/example.jpg');
#3

[eluser]Piatra[/eluser]
funny thing is it works for some paths
#4

[eluser]Mike DeFelice[/eluser]
I think I was confused, I thought you tried doing file_exists('http://www.example.com/test.jpg'); sorry about that!
#5

[eluser]Piatra[/eluser]
[quote author="Mike DeFelice" date="1295756196"]I think I was confused, I thought you tried doing file_exists('http://www.example.com/test.jpg'); sorry about that![/quote]

This is an example path
Code:
http://localhost/website/upload/1295355758768_thumb.jpg
#6

[eluser]Mike DeFelice[/eluser]
file_exists() seems to only work for files on your server, not being able to use urls as the path. You can use some sort of curl function to do this, there are a lot of examples on the php site.

http://php.net/manual/en/function.file-exists.php




Theme © iAndrew 2016 - Forum software by © MyBB