當前位置:首頁 » 編程語言 » phpcurl下載

phpcurl下載

發布時間: 2022-04-22 19:55:48

A. 請問高手,如何解決php的curl內存不夠的問題呢

curl下載的文件內容是可以直接輸出到文件,而不是內存,請設置這個選項:

$fp=fopen('temp.jpg','w');
curl_setopt($c,CURLOPT_RETURNTRANSFER,false);
curl_setopt($c,CURLOPT_FILE,$fp);


也可以通過設置memory_limit來提高最大內存使用量

ini_set('memory_limit','1024M');


您的採納就是我的動力!

B. 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;
}

C. 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

D. PHP CURL 獲取遠程數據下載

這樣做肯定是用的你的帶寬,是把文件下載到你的伺服器上,然後再下載給客戶端。

有兩條路你可以去試試看,我沒做過:一是setcookie指定域名是那個網站,然後轉向:
setcookie ($cname ,$cvalue ,$expire ,$path , $host);
header('location: $url");

另外一個方法類似,好像有個P3P可以傳遞COOKIE,需要你自己查資料:
setcookie ($cname ,$cvalue);
header('P3P: ....');
header('location: $url");

第二個辦法應該是可以的,陶寶和開心網都在用這樣的技術,陶寶有許多域名,一次登錄後都可以使用,就是利用P3P實現的COOKIE傳遞。

E. php curl 下載保存時文件類型怎麼確定

curl,一般都用來抓取網頁內容。
返回值是字元流
你把它保存成.html後綴就行了

F. 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保存下載內容為文件

G. PHP 通過curl下載ftp文件,怎麼設置埠號

ftp://172.19.71.63:8080/Flipped.2010.BluRay.720p.DTS.x264-CHD.sample.mkv

H. 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>

I. windows 的php環境下 用curl遠程下載速度慢

使用fsockopen

J. PHP利用curl下載電商平台訂單出現500 Internal Server Error

數據量大時處理就會久,這種情況下出現500是多數因為執行超時
首先,建議你利用其他語言來完成大量數據獲取的功能
php的話,要麼分批獲取,就是不要一次性獲取完,避免超時返回500,要麼使用命令行來執行php腳本完成該任務

熱點內容
內置存儲卡可以拆嗎 發布:2025-05-18 04:16:35 瀏覽:333
編譯原理課時設置 發布:2025-05-18 04:13:28 瀏覽:375
linux中進入ip地址伺服器 發布:2025-05-18 04:11:21 瀏覽:610
java用什麼軟體寫 發布:2025-05-18 03:56:19 瀏覽:31
linux配置vim編譯c 發布:2025-05-18 03:55:07 瀏覽:107
砸百鬼腳本 發布:2025-05-18 03:53:34 瀏覽:940
安卓手機如何拍視頻和蘋果一樣 發布:2025-05-18 03:40:47 瀏覽:739
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:802
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:510
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:371