Blog Yazısı

Uzak Sunucuda Dosya Kontrolü

Php ile uzak sunucuda bir dosyanın var olup olmadığını kontrol edebiliriz. Bu kontrol için bir fonksiyon işimizi görebilir. Dosya kontrolü yapan get_headers() fonksiyonunu kullanacağız. Aşağıda örnek kullanımı da mevcuttur.
<?php

$file = get_headers('http://www.harunalp.com/siteler/tema1.zip');

if( $file['0'] == 'HTTP/1.1 200 OK' ) {
    print 'dosya mevcut';
} else {
    print 'dosya yok';
}

?>
 

← Bloga dön

Son yazılar