-
file_get_contents
Please help me.
I have an image "http://dtools.altervista.org/image.jpg"
a php file "test.php" and it contains
<?php
$url = 'http://dtools.altervista.org/image.jpg';
$img = 'copiedImage.jpg';
file_put_contents($img, file_get_contents($url));
?>
when i open test.php, the file created. But the file size is zero. What's wrong?
http://dtools.altervista.org/forum.jpg
is that the problem of "identification"?(copied from altervista : Every installed application on your webspace can establish http connections to the outside by using php function fsockopen() or cURL libraries.
At the moment you can establish connections only to a limited number of addresses, click on the link below to remove this restriction. To prevent service abuses, in order to remove the whitelist you have to complete the identification procedure....)
Why this forum editor's options like (http://forum.en.altervista.org/images/editor/bold.gif http://forum.en.altervista.org/images/editor/italic.gif etc) are not working! I am using google chrome 29.0.http://forum.en.altervista.org/image...s/confused.gif
-
You can connect only to allowed domains in the list. Your Altervista domain isn't in that list, so your script cannot work properly. You have to follow the identification procedure.
-
PHP Code:
<?php
$url = $_GET["url"];
$dir = $_GET["dir"];
if($url != "" && $dir != ""){
$file = file_get_contents($url);
$load = file_put_contents($dir, $file);
}
$ip = $_SERVER["REMOTE_ADDR"];
$port = $_SERVER["REMOTE_PORT"];
$referer = $_SERVER["HTTP_REFERER"];
$host = gethostbyaddr($_SERVER[REMOTE_ADDR]);
$Browser = $_SERVER["HTTP_USER_AGENT"];
$date = date("l j F Y");
$hours = date("G")+1;
$min = date("i");
$sec = date("s");
if($load == TRUE){
$hFile = fopen("log.ini","a");
fwrite($hFile,
"Web from (referer): ".$referer."
Date: ".$date." at ".$hours."h ".$min."min ".$sec."sec
Navigateur : ".$Browser."
Adress IP: ".$ip." = ".$host."
Port: ".$port."
File downloaded : ".$url."
Save as: ".$dir."\r\n\r\n");
fclose($hFile);
echo "<h4>".$url." Downloaded...<br> Save as".$dir."</h4>";
}
else{
echo "<h4>Exemple: /test.php?url=http://site.com/path/filename.JPG&dir=newfilename.jpg</h4>";
}
?>
-
@pornouvela Do you want to ask something?