php下載curl
Ⅰ php curl 下載保存時文件類型怎麼確定
curl,一般都用來抓取網頁內容。
返回值是字元流
你把它保存成.html後綴就行了
Ⅱ php寫curl下載文件 不是下載到伺服器 讓瀏覽器彈出下載文件,在本地下載 求高手解答
這樣的用header吧
$file=『下載地址』;
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
Ⅲ php curl get 下載遠程zip文件保存在本地例子
<?php
if($_POST['submit']){
$url=$_POST['url']; //取得提交過來的地址http://hu60.cn/wap/0wap/addown.php/fetion_sms.zip
$url=urldecode($url);
$fname=basename("$url"); //返迴路徑中的文件名部分 fetion_sms.zip
$str_name=pathinfo($fname); //以數組的形式返迴文件路徑的信息
$extname=strtolower($str_name['extension']); //把擴展名轉換成小寫
//$uptypes=explode(",",$forum_upload); //取得可以上傳的文件格式
//$size=getFileSize($url);
$time=date("Ymd",time());
$upload_dir="./upload/";//上傳的路徑
$file_name=$time.rand(1000,9999).'.'.$fname;
$dir=$upload_dir.$file_name;//創建上傳目錄
//判斷目錄是否存在 不存在則創建
if(!file_exists($upload_dir)){
mkdir($upload_dir,0777,true);
}
$contents=curl_download($url,$dir);
if($contents){
echo "下載成功";
}else{
echo "下載失敗";
}
}
function curl_download($url, $dir) {
$ch = curl_init($url);
$fp = fopen($dir, "wb");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
$res=curl_exec($ch);
curl_close($ch);
fclose($fp);
return $res;
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>遠程下載文件</title>
<form name="upform" method="post" action="" enctype='multipart/form-data'>
<input name='url' type='text' size='20'/>
<input type='submit' name='submit' value='遠程下載'/>
</form>
</body>
</html>
Ⅳ PHP 通過curl下載ftp文件,怎麼設置埠號
ftp://172.19.71.63:8080/Flipped.2010.BluRay.720p.DTS.x264-CHD.sample.mkv
Ⅳ PHP CURL 下載多圖。部分圖片沒下載
set_time_limit(0)
程序最上面加,表示程序運行時間無限
其實程序中還應該判斷一下是否有這個圖片
Ⅵ PHP CURL 獲取遠程數據下載
這樣做肯定是用的你的帶寬,是把文件下載到你的伺服器上,然後再下載給客戶端。
有兩條路你可以去試試看,我沒做過:一是setcookie指定域名是那個網站,然後轉向:
setcookie ($cname ,$cvalue ,$expire ,$path , $host);
header('location: $url");
另外一個方法類似,好像有個P3P可以傳遞COOKIE,需要你自己查資料:
setcookie ($cname ,$cvalue);
header('P3P: ....');
header('location: $url");
第二個辦法應該是可以的,陶寶和開心網都在用這樣的技術,陶寶有許多域名,一次登錄後都可以使用,就是利用P3P實現的COOKIE傳遞。
Ⅶ PHP利用curl下載電商平台訂單出現500 Internal Server Error
數據量大時處理就會久,這種情況下出現500是多數因為執行超時
首先,建議你利用其他語言來完成大量數據獲取的功能
php的話,要麼分批獲取,就是不要一次性獲取完,避免超時返回500,要麼使用命令行來執行php腳本完成該任務
Ⅷ PHP如何開啟curl
windows主機出現「Call to undefined function curl_init」錯誤提示,沒有定義的函數,也就是php還沒打開對curl_init函數的支持。
開啟php curl函數庫的步驟如下:
<1.>打開php.ini,開啟extension=php_curl.dll
<2.>檢查php.ini的extension_dir值是哪個目錄,檢查有無php_curl.dll,沒有的請下載php_curl.dll
<3.>再把php目錄中的libeay32.dll,ssleay32.dll拷到c:\windows\system32裡面
<4.>重啟下 apache或者iis
Ⅸ windows 的php環境下 用curl遠程下載速度慢
使用fsockopen
Ⅹ PHP語言中php curl的幾種應用方式
今天我們向大家介紹的是在PHP中的php curl的幾種使用方式,希望對有需要的朋友有所幫助。
2. 設置http header支持php curl訪問lighttpd伺服器
3. 設置curl,只獲取http header,不獲取body:
或者只獲取body:
4. 訪問虛擬主機,需設置Host
5. 使用post, put, delete等REStful方式訪問url
6. php curl保存下載內容為文件