search
Homephp教程PHP源码php 采集远程图片(可采集防盗链)

<script>ec(2);</script>

//变量说明:
// $url 是远程图片的完整url地址,不能为空。
// $filename www.111cn.net是可选变量: 如果为空,本地文件名将基于时间和日期
// 自动生成.

 代码如下 复制代码

function grabimage($url,$filename="") {
  if($url==""):return false;endif;

  if($filename=="") {
    $ext=strrchr($url,".");
    if($ext!=".gif" && $ext!=".jpg"):return false;endif;
    $filename=date("dmyhis").$ext;
  }

  ob_start();
  readfile($url);
  $img = ob_get_contents();
  ob_end_clean();
  $size = strlen($img);

  $fp2=@fopen($filename, "a");
  fwrite($fp2,$img);
  fclose($fp2);

  return $filename;
}

//如果可用采集防采集的功能把fopen改成111cn.net

 代码如下 复制代码

$ch = curl_init();
curl_setopt($ch, curlopt_url, $url);//这是目标地址
curl_setopt($ch, curlopt_header, 0);
curl_setopt($ch, curlopt_returntransfer, 1);
curl_setopt($ch, curlopt_referer,   $referer);//这里伪造
$data = curl_exec($ch);
curl_close($ch);
echo $data;

 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools