如何在本地服务器上用php或cakephp保存来自youtube的图像
在这段代码中,空白图像存储。不是原始图像存储。您只是在编写缩略图url,而不是图像的内容。您必须从url获取图像的内容并将其写入图像文件 下面是fopen、fwrite的捷径 或如何在本地服务器上用php或cakephp保存来自youtube的图像,php,cakephp,cakephp-1.3,cakephp-1.2,Php,Cakephp,Cakephp 1.3,Cakephp 1.2,在这段代码中,空白图像存储。不是原始图像存储。您只是在编写缩略图url,而不是图像的内容。您必须从url获取图像的内容并将其写入图像文件 下面是fopen、fwrite的捷径 或 您只是在编写缩略图url,而不是图像的内容。您必须从url获取图像的内容并将其写入图像文件 下面是fopen、fwrite的捷径 或 $thumbnail_url = 'http://img.youtube.com/vi/JaFfJN_iKdA/default.jpg'; function save_image_l
您只是在编写缩略图url,而不是图像的内容。您必须从url获取图像的内容并将其写入图像文件 下面是fopen、fwrite的捷径 或
$thumbnail_url = 'http://img.youtube.com/vi/JaFfJN_iKdA/default.jpg';
function save_image_local($thumbnail_url)
{
//for save image at local server
$filename = time().'_hk.jpg';
$fullpath = '../../app/webroot/img/daily_videos/image/'.$filename;
$fp = fopen($fullpath,'x');
fwrite($fp, $thumbnail_url);
fclose($fp);
}
$img_content=file_get_contents($thumbnail_url);
file_put_contents($fullpath,$img_content );
$img_content=file_get_contents($thumbnail_url);
$fp = fopen($fullpath,'x');
fwrite($fp, $img_content);
fclose($fp);