Bir dosya harici bir sunucuya olmadığını denetlemek nasıl

2 Cevap

Bir dosya Harici Server olmadığını denetlemek nasıl? Ben bir url "http://logs.com/logs/log.csv" var ve bu dosya varsa kontrol etmek için başka bir sunucuda bir komut dosyası var. Denedim

$hvele = fopen("http://logs.com/logs/log.csv","r");
if($hvele === true){
return true;
}else{
return false;
}

ve

if(file_exists("http://logs.com/logs/log.csv")){
return true;
}else{
return false;
}

Bu methos işe yaramayan

2 Cevap

  1. Emin hata raporlama üzerinde olduğundan emin olun.

  2. Kullan if($handle)

  3. allow_url_fopen doğru olup olmadığını kontrol edin.

  4. Bu hiçbiri işe yaramazsa, kullanmak this method on the file_exists page.

Bu çalışması gerekir:

$contents = file_get_contents("http://logs.com/logs/log.csv");

if (strlen($contents))
{
  return true; // yes it does exist
}
else
{
  return false; // oops
}

Note: Bu dosya boş değil varsayar