0

OK, I have been struggling for about 2 days on this. I can get an image from youtube like this,

$filename = $video_id . '.jpg';
$youtube_thumb_url = "https://img.youtube.com/vi/". $video_id . "/maxresdefault.jpg"; 
$imagedata = file_get_contents($youtube_thumb_url) ;

this is where I am stuck, how do I save this back to a .jpg file? I tried this,

$imagedata->move('uploads', $filename );

But that did not work, because $imagedata is a string.

I thought of trying to convert $imagedata, but I cant figure out what the format of is.

Help Please. Bill

Bill
  • 23
  • 4

2 Answers2

0

You can try using curl to get images from uri, then save the image

Save image from url with curl PHP

0

file_put_contents(): Writes a string or array to a file.

http://php.net/manual/en/function.file-put-contents.php

Andy White
  • 438
  • 2
  • 11