php:获取文件内容和存储在特定文件夹中的文件
问题描述:
我从php中获取file_get_contents()
函数的文件内容,我想将该文件存储在特定文件夹中。我会怎么做?php:获取文件内容和存储在特定文件夹中的文件
$image = file_get_contents('http://www.affiliatewindow.com/logos/1961/logo.gif');
我想将此图像保存在特定文件夹中。
有什么想法吗?
答
$image = file_get_contents('http://www.affiliatewindow.com/logos/1961/logo.gif');
file_put_contents('./myDir/myFile.gif', $image);
答
如果你使用PHP 5中,你可以使用file_put_contents
:
file_put_contents('/path/to/file.dat', $data);