file_put_contents is not working for the following code? (I used xampp)
I try:
$url =
'http://localhost/main_assets/images/company/news/142861-Spring-Break-main-pic.jpg';
$file_name = basename($url);
echo "url:";
var_dump($url);
echo "file_name:";
var_dump($file_name);
if (file_put_contents($file_name, file_get_contents($url)))
{
echo "File downloaded successfully";
}
else
{
echo "File downloading failed.";
}
result:
url:
C:\xampp\htdocs\sitemaker\a_php_codes\controllers\testurl\ctrl_index.php:16:string 'http://localhost/main_assets/images/company/news/142861-Spring-Break-main-pic.jpg' (length=81)
file_name:
C:\xampp\htdocs\sitemaker\a_php_codes\controllers\testurl\ctrl_index.php:19:string '142861-Spring-Break-main-pic.jpg' (length=32)
File downloaded successfully
but there is no file in the following directory:
C:\xampp\htdocs\sitemaker\a_php_codes\controllers\testurl\
I can see the image when I enter the address to the browser;
result no file no error ...!!
I do some search but most result is because of permission issue.
I check the folders permission: