Forum Moderators: coopster
error_reporting(0);
$there = include('isp.server/~myaccount/bummer.txt');
if ($there){
$url="isp.server/~myaccount/";
}else{
$url="";
}
This is a 1x20 default labeled command window. Right-click on image and select save as to download.
<a href="<?php print $url;?>path/file1.xml">
<img src="<?php print $url;?>images/imageoffile1.png" /></a>
The bummer.txt file is an empty text file that resides on the remote server.
This works just fine. I am just wondering is there a better way to do this?
Thanks,
Tim
$there = include('isp.server/~myaccount/bummer.txt');
If the remote server is available the variable $there will contain the contents of bummer.txt which in this case is nothing as bummer.txt is blank. However $there is not NULL so I can then set the variable $url to the remote server.
If the remote server is unavailable the varible $there will be NULL and I'll know to set the $url variable to my local server.
What I am asking is there a better way to check for the availability of a requested file(s) on the remote server?
I hope that clears it up.
Thanks
<I am just wondering is there a better way to do this?>
Are you having any issues using this method? It looks like it would work sufficiently. I'm not sure why you'd be interested in changing it.
As far as availability goes, it depends on the reason the images may not be available. If the consistent problem is that your ISP's server is down, or their network connection goes down, then this method would be just fine.
On the other hand, if they are having file system problems whereas some files are available and others are not, then proving that bummer.txt is available doesn't prove that the requested image is also. The way to do that would be to include the image instead. The problem, of course, is that it doesn't help with the bandwidth issue you're looking to avoid in the first place :-).
I would assume the former (that your ISP's network is having issues), so either the entire server is available or it's not. Therefore, I believe your current method to be just fine.