国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? php教程 php手冊(cè) gd庫(kù)圖片下載類實(shí)現(xiàn)下載網(wǎng)頁(yè)所有圖片的php代碼

gd庫(kù)圖片下載類實(shí)現(xiàn)下載網(wǎng)頁(yè)所有圖片的php代碼

Jun 13, 2016 am 11:59 AM
content header php ???? ?? ??? ???? ?? ???? ??? ~? ??? ????

php代碼如下:

復(fù)制代碼 代碼如下:


header("Content-type:text/html ; charset=utf-8");
if (!empty($_POST['submit'])){
$url = $_POST['url'];
//為了獲取相對(duì)路徑的圖片所做的操作
$url_fields = parse_url($url);
$main_url = $url_fields['host'];
$base_url = substr($url,0,strrpos($url, '/')+1);
//獲取網(wǎng)頁(yè)內(nèi)容
//設(shè)置代理服務(wù)器
$opts = array('http'=>array('request_fulluri'=>true));
$context = stream_context_create($opts);
$content = file_get_contents($url,false,$context);
//匹配img標(biāo)簽,將所有匹配字符串保存到數(shù)組$matches
$reg = "/gd庫(kù)圖片下載類實(shí)現(xiàn)下載網(wǎng)頁(yè)所有圖片的php代碼/i";
preg_match_all($reg, $content, $matches);
$count = count($matches[0]);
for ($i=0; $i/*將所有圖片的url轉(zhuǎn)換為小寫
*$matches[1][$i] = strtolower($matches[1][$i]);
*/
//如果圖片為相對(duì)路徑就轉(zhuǎn)化為全路徑
if (!strpos('a'.$matches[1][$i], 'http')){
//因?yàn)?/'是第0個(gè)位置
if (strpos('a'.$matches[1][$i], '/')){
$matches[1][$i] = 'http://'.$main_url.$matches[1][$i];
}else{
$matches[1][$i] = $base_url.$matches[1][$i];
}
}
}
//過(guò)濾重復(fù)的圖片
$img_arr = array_unique($matches[1]);
//實(shí)例化圖片下載類
$getImg = new DownImage();
$url_count = count($img_arr);
for ($i=0; $i$getImg->source = $img_arr[$i];
$getImg->save_address = './pic/';
$file = $getImg->download();
}
echo "下載完成!哈哈,簡(jiǎn)單吧!";
}
class DownImage{
public $source;//遠(yuǎn)程圖片URL
public $save_address;//保存本地地址
public $set_extension; //設(shè)置圖片擴(kuò)展名
public $quality; //圖片的質(zhì)量(0~100,100最佳,默認(rèn)75左右)
//下載方法(選用GD庫(kù)圖片下載)
public function download(){
//獲取遠(yuǎn)程圖片信息
$info = @getimagesize($this->source);
//獲取圖片擴(kuò)展名
$mime = $info['mime'];
$type = substr(strrchr($mime, '/'), 1);
//不同的圖片類型選擇不同的圖片生成和保存函數(shù)
switch($type){
case 'jpeg':
$img_create_func = 'imagecreatefromjpeg';
$img_save_func = 'imagejpeg';
$new_img_ext = 'jpg';
$image_quality = isset($this->quality) ? $this->quality : 100;
break;
case 'png':
$img_create_func = 'imagecreatefrompng';
$img_save_func = 'imagepng';
$new_img_ext = 'png';
break;
case 'bmp':
$img_create_func = 'imagecreatefrombmp';
$img_save_func = 'imagebmp';
$new_img_ext = 'bmp';
break;
case 'gif':
$img_create_func = 'imagecreatefromgif';
$img_save_func = 'imagegif';
$new_img_ext = 'gif';
break;
case 'vnd.wap.wbmp':
$img_create_func = 'imagecreatefromwbmp';
$img_save_func = 'imagewbmp';
$new_img_ext = 'bmp';
break;
case 'xbm':
$img_create_func = 'imagecreatefromxbm';
$img_save_func = 'imagexbm';
$new_img_ext = 'xbm';
break;
default:
$img_create_func = 'imagecreatefromjpeg';
$img_save_func = 'imagejpeg';
$new_img_ext = 'jpg';
}
//根據(jù)是否設(shè)置擴(kuò)展名來(lái)合成本地文件名
if (isset($this->set_extension)){
$ext = strrchr($this->source,".");
$strlen = strlen($ext);
$newname = basename(substr($this->source,0,-$strlen)).'.'.$new_img_ext;
}else{
$newname = basename($this->source);
}

//生成本地文件路徑
$save_address = $this->save_address.$newname;
$img = @$img_create_func($this->source);
if (isset($image_quality)){
$save_img = @$img_save_func($img,$save_address,$image_quality);
}else{
$save_img = @$img_save_func($img,$save_address);
}
return $save_img;
}
}
?>


遠(yuǎn)程url地址:



運(yùn)行結(jié)果如圖:

下載的圖片本例中保存在當(dāng)前目錄的pic文件夾下!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

?? ??

?? : ????? ????? ??
3 ? ? ? By DDD
?? ?? ??
3 ? ? ? By Jack chen
???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

?? ????
1787
16
Cakephp ????
1730
56
??? ????
1582
29
PHP ????
1448
31
???
PHP ??? ?? ??? ??? PHP ??? ?? ??? ??? Jul 18, 2025 am 04:25 AM

PHP ??? ??? ?? ??? ????? php.ini? ???? ? ??? ???? ??? ??? ????? ????. 1. PHP ?? : Linux ? APT, Mac ? Homebrew ? Windows? ???? XAMPP ??; 2. php.ini ?? : ?? ???, ??? ?? ?? ???? ??? ?? ?????. 3. ? ?? ?? : Apache? mod_php? ???? nginx? php-fpm? ?????. 4. ?? ??? ???? ?? ????? ???? ?? : MySQLI, JSON, MBString ?? ?? ??.

?? PHP : ??? ??? ?? PHP : ??? ??? Jul 18, 2025 am 04:54 AM

tolearnpheffectical, startBysetTupaloCalserErverEnmentUsingToolslikexamppandacodeeditor -likevscode.1) installxamppforapache, mysql, andphp.2) useacodeeditorforsyntaxsupport.3)) 3) testimplephpfile.next, withpluclucincludechlucincluclucludechluclucled

???? PHP ?? ?? ???? PHP ?? ?? Jul 18, 2025 am 04:44 AM

?? ??????? ??? ?? ?? ??? ?? ????? ??? ???? ??? ????? ??? ??? ??? ??? ? ? ????. ??? ??? ??? ?? ???? ???? ?? ? ? ????. ??? ????? ???? ??? ??? ??, ?? ?? ?? ?? ? ?? ?? ??? ?????. ??? ?????? ???? ??? ??? ???? ? ? ??? ????? ??? ???? ????. ?? ?? ??? ???? ??, ??? ? ??? ?? ???? ?? ?? ? ?? ?? ???? ??? ????????. ??? ??? ?? ??? ??? ???? ?? ??? ?? ? ? ????. ??? ??? ???? ?? ??? ???? ?? ?? ?? ??? ??????.

PHP ?? ?? ? PHP ?? ?? ? Jul 18, 2025 am 04:51 AM

PHP ??? ???? ??? ??? ??? ????? ????. ??? ????? ?? ???? ??? "?? ? ?"??? "?"? ???????. 1. ??? ? ??? ??? DocBlock (/*/)? ?? ?? ??? ???? ??? ? ?? ???? ??????. 2. JS ??? ???? ?? ???? ??? ?? ??? ??? ?????. 3. ??? ?? ?? ?? ??? ???? ????? ????? ???? ?? ????? ???? ? ??????. 4. Todo ? Fixme? ????? ???? ? ? ??? ??? ???? ?? ?? ? ??? ???????. ??? ???? ?? ??? ??? ?? ?? ?? ???? ???? ? ????.

?? PHP ?? ??? ?? PHP ?? ??? Jul 18, 2025 am 04:52 AM

toinstallphpquickly, usexampponwindowsorhomebrewonmacos.1. ??, downloadandinstallxAmpp, selectComponents, startApache ? placefilesinhtdocs.2

PHP ?? ?? ??? ? PHP ?? ?? ??? ? Jul 18, 2025 am 04:35 AM

phpblockommentsearseforwritingmulti-lleexplanations, temporlyblingcode, and generatingdocumentation.theyshouldnotbenesteTeRleftUnclosed.blockmentShelPindOcumentingFunctionSwitHphPDoc, whatlsoompsTormuseforauto-CompletionAnderRorChe

???? ??? ?? ???? ??? ?? Jul 18, 2025 am 04:46 AM

?? ??? ???? ??? ??? ???? ????? ?? "?? ? ?"? ??? "?"? ???? ????. 1. ??? ?? ?? ?? ??? ?? ??? ?? ??? ??? ???????. 2. ??? ??? ?? ?? ??? ???? ?? ?? ????? ???? ????? ?????. 3. ????? ??? ???? ??? ???? ????, ???? ???, ??? ?? ?? ???? ?????. 4. ??? ?? ? ? ??? ??? ???? ?? ??? ??? ??? ?? ??? ?? ?? ??? ??????.

PHP?? ?? ?? PHP?? ?? ?? Jul 18, 2025 am 04:57 AM

PHP ?? ???? ? ?? ???? ??? ????. 1. // ?? #? ???? ? ?? ??? ???? // ???? ?? ????. 2. ?? /.../ ?? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ? ????. 3. ?? ?? ?? / if () {} /? ?? ?? ??? ????? ??? ?? ?? ?? ??? ???? ????? ???? ??? ?? ???? ???? ??? ? ??? ??????.

See all articles