- Script window. SC = ""; script
2. curl method usage:
- Http: // your-domain-name/showpic. php? Url = image_url
3. the PHP header sends download file names of various types: showpic. php
- $ Url = $ _ GET ["url"];
- // $ Url = str_replace ("http:/", "http: //", $ url );
- $ Dir = pathinfo ($ url );
- $ Host = $ dir ['dirname'];
- $ Refer = $ host .'/';
- $ Ch = curl_init ($ url );
- Curl_setopt ($ ch, CURLOPT_REFERER, $ refer );
- Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); // activate the modifiable page, Activation can modify the page
- Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
- Curl_setopt ($ ch, CURLOPT_BINARYTRANSFER, 1 );
- $ Data = curl_exec ($ ch );
- Curl_close ($ ch );
- $ Ext = strtolower (substr (strrchr ($ img, '.'), 1, 10 ));
- $ Types = array (
- 'Gif' => 'image/GIF ',
- 'Jpeg '=> 'image/jpeg ',
- 'Jpg '=> 'image/jpeg ',
- 'Jpe' => 'image/jpeg ',
- 'PNG '=> 'image/png ',
- );
- $ Type = $ types [$ ext]? $ Types [$ ext]: 'image/jpeg ';
- Header ("Content-type:". $ type );
- Echo $ data;
- ?>
The error "Cannot modify header information headers already sent" is reported in PHP because no content is output before the code, including blank content. remember!
With the above code, you can display the image as follows:
It's really amazing. php image anti-Leech protection does not hold the defense line, haha. |