问题描述
嗨..我必须使用php将weblink中的图像下载到我的本地文件夹。以下是该计划。我可以成功下载图像,但是当我尝试打开它时显示文件已被损坏。下面是代码片段
$ URL ='http://10.251.13.7/gtz/temp3.php/download.png'; //喜欢http:// ....
$ FileToSave ='uploads / download.png'; //喜欢/ home / ..或C:/ ...
$ Content = file_get_contents($ URL);
file_put_contents($ FileToSave,$内容);
我尝试过:
Hi..I have to download an image in a weblink to my local folder using php. Below is the program. I could successfully download the image , but when i try to open it is showing the file has been damaged.Below is the code snippet
$URL = 'http://10.251.13.7/gtz/temp3.php/download.png'; // Like "http:// ...."
$FileToSave = 'uploads/download.png'; // Like "/home/.." or "C:/..."
$Content = file_get_contents($URL);
file_put_contents($FileToSave, $Content);
What I have tried:
$URL = 'http://10.251.13.7/gtz/temp3.php/download.png'; // Like "http:// ...."
$FileToSave = 'uploads/download.png'; // Like "/home/.." or "C:/..."
$Content = file_get_contents($URL);
file_put_contents($FileToSave, $Content);
推荐答案
这篇关于在PHP中使用file_get_contents和file_put_contents的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!