$image = file_get_contents('http://82.177.67.40:65530/test/stok.jpg') or die('Nie mozna przechwycic obrazu');
działa on idealnie na moim lokalnym serwerze, ale na x10hosting.com na którym mam konto zablokowane jest file_get_contents. Dlatego musiałem znaleźć alternatywe przez cURL i chyba cos mi ta alternatywa nie działa:) Oto ona:
function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser. curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); return $data; } $image = file_get_contents_curl('http://82.177.67.40:65530/test/stok.jpg') or die('Nie mozna przechwycic obrazu');
Skrypt zapisuje mi plik o danej nazwie prawidłowo ale jest on pusty i ma rozszerzenie .txt. Mógłby mi ktoś z tym pomóc, tak aby zapisywało obraz do zadanego folderu bez file_get_contents? Z góry dzięki za pomoc!