@Sample;
Verilen URL'deki resmi dizine kaydetmek için şu fonksiyonu kullanabilirsiniz.
<?php
function save_file($url, $name, $dir) {
$full_path = $dir . $name;
$response = file_get_contents($url);
$handle = fopen($full_path, "w+");
fwrite($handle, $response);
fclose($handle);
return file_exists($full_path);
}
# ÖRNEK KULLANIM
$save_file = save_file("https://www.r10.net/images/misc/vbulletin3_logo_white.gif", "vbulletin3_logo_white.gif", str_replace("\\", "/", dirname(realpath(__FILE__))));
var_dump($save_file); ## dönen değer "true" veya "false" olacaktır. (bool cinsinden)