开发者

php : get file contents and store file in particular folder

I am getting file contents from the file_get_contents() function in php and I want to store that file in a particular f开发者_C百科older. How would I do that?

$image = file_get_contents('http://www.affiliatewindow.com/logos/1961/logo.gif');

I want to save this image in particular folder.

any idea about it?


Use file_put_contents()

$image = file_get_contents('http://www.affiliatewindow.com/logos/1961/logo.gif');
file_put_contents('./myDir/myFile.gif', $image);


If you're using php 5, you can use file_put_contents:

file_put_contents('/path/to/file.dat', $data);


Apart from the mentioned file_put_contents, you could take a look at the example of the fwrite function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜