Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php : get file contents and store file in particular folder

Tags:

I am getting file contents from the file_get_contents() function in php and I want to store that file in a particular folder. 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?

like image 223
Sanjay Khatri Avatar asked Apr 28 '10 11:04

Sanjay Khatri


2 Answers

Use file_put_contents()

$image = file_get_contents('http://www.affiliatewindow.com/logos/1961/logo.gif'); file_put_contents('./myDir/myFile.gif', $image); 
like image 149
Yacoby Avatar answered Oct 26 '22 12:10

Yacoby


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

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

like image 37
Adam Hopkinson Avatar answered Oct 26 '22 13:10

Adam Hopkinson