今天想要php 的curl下载mp4文件,但是下载后的文件大小怎么是0kb?
<?php $source = "https://repo.bfw.wiki/bfwrepo/video/modushanghai.mp4"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $source); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSLVERSION, 3); $data = curl_exec ($ch); $error = curl_error($ch); curl_close ($ch); $destination = "/data/wwwroot/default/Data/video.mp4"; $file = fopen($destination, "wb"); fwrite($file, $data); fclose($file);

网友回复
这个代码不对,改成下面的写法就可以了
<?php $filename = "/data/wwwroot/default/Data/video.mp4"; //路径文件名 $file = "https://repo.bfw.wiki/bfwrepo/video/modushanghai.mp4"; download_img($file, $filename); function download_img($url, $filename) { // $COOKIE_file = dirname...
点击查看剩余70%