Jump to content

Check if file exists, BUT in file...


willdk

Recommended Posts

Hello,

 

I use this code in my script,

 

.(file_exists('/home/test/domains/mydomain.com/public_html/files/0123.jpg')? "http://www.mydomain.com/files/0123.jpg": "http://www.mydomain.com/files/nofile.jpg").

 

But can I check if the file exists in for example files.txt and not the file itself?

 

file.txt:

0123.jpg
0126.jpg
...

???

Link to comment
https://forums.phpfreaks.com/topic/149222-check-if-file-exists-but-in-file/
Share on other sites

try

$files = file("file.txt");
foreach($files as $file){
    echo file_exists('/home/test/domains/mydomain.com/public_html/files/$file')? "http://www.mydomain.com/files/$file": "http://www.mydomain.com/files/nofile.jpg") . "<br />";
}

untested but i think it should work

 

Scott.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.