更新时间:2023-09-05 13:32:52
您应该可以为此使用file_get_contents
.为了在file_get_contents
中使用URL,请确保在php.ini
文件中启用了allow_url_fopen
.
You should be able to use file_get_contents
for this one. In order to use an URL with file_get_contents
make sure allow_url_fopen
is enabled in you php.ini
file.
define('DIRECTORY', '/home/user/uploads');
$content = file_get_contents('http://anothersite/images/goods.jpg');
file_put_contents(DIRECTORY . '/image.jpg', $content);
确保对要存储图像的目录具有写权限;要使该文件夹可写,您可以执行以下操作:
Make sure that you have write permission to the directory where you want to store the image; to make the folder writable you could do this:
chmod +w /home/users/uploads
参考