Reputation: 1
I'm trying to figure out how to pull an image from a third party website that gets changed every so often. Basically I am using Vbulletin software and would like to avoid a mixed content warning - hosting an image (HTTP) from another site onto mine (HTTPS). I would like the function basically to call the image in php, save the image to a folder on my server and then a php function to call the saved image on my server and display it. Thoughts? Thanks. I keep getting a failure to open stream on file_get_contents...
ob_start();
//Get the file
$content = file_get_contents("http://www.defconwarningsystem.com/current/defcon.jpg");
//Store in the filesystem.
$fp = fopen("/images/defcon/defcon.jpg", "w");
fwrite($fp, $content);
fclose($fp);
$html = ob_get_clean();
return $html;
Upvotes: 0
Views: 177
Reputation: 1744
If file_get_contents doesn't work try cURL. See example usage on php reference
Upvotes: 1
Reputation: 996
Change
$content = file_get_contents("http://www.defconwarningsystem.com/current/defcon.jpg");
To
$content = file_get_contents("//defconwarningsystem.com/current/defcon.jpg");
And see if that works.
Upvotes: 1