I am importing data from an XML file including .jpg files and I am using the copy command. All works well unless the remote file is missing when I get an error.
Following advice from a colleague I have tried using getimagesize() but if the image doesnt exist I am still getting an error message "failed to open stream" and the loop that I use to import from the XML just stops. Can anybody help please?
function remote_file_exists($file){
$url=getimagesize($file);
if(is_array($url)){
return 1;
}else{
return 0;
}
}
if(remote_file_exists($ffrom)<=0){
echo "The image doesn't exist";
}else{
copy($ffrom,$tto);
}
Following advice from a colleague I have tried using getimagesize() but if the image doesnt exist I am still getting an error message "failed to open stream" and the loop that I use to import from the XML just stops. Can anybody help please?
function remote_file_exists($file){
$url=getimagesize($file);
if(is_array($url)){
return 1;
}else{
return 0;
}
}
if(remote_file_exists($ffrom)<=0){
echo "The image doesn't exist";
}else{
copy($ffrom,$tto);
}