Hi, i found that "file_exists" only check the file from the same server (domain), but now I need to check whether a file from the other site is exist or not...
for example : I placed a product pictures on the site B. now, I build a new site (we called it site A). here in site A, I want to display the picture files from site B into site A... yes, I can easily use <img src='http://www.b.com/picture.jpg'> but I also want to display the "no-pic.jpg" if the file doesn't exist...
any solution for these ?
thanks a lot...
check a file from other site
Moderator: General Moderators
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
A JS approach...
But since everybody may not have enabled JS, you may wnat to look at the other alternatives.
EDIT: I think CURL may be an altrenative for you. look into it.
Code: Select all
<img src="e;http://www.b.com/picture.jpg"e; onerror="e;this.src='no-pic.jpg'"e;>EDIT: I think CURL may be an altrenative for you. look into it.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
curl may be the better option indeed, as it allows for you to set a quick timeout. I would suggest caching the results of a remote page query for a while, as performing several on a page will make the page respond quite slow.