How to add an automatic thumbnail image to the PHP download

Source: Internet
Author: User
Tags php download
This PHP was originally to the titlepic in the chain image automatically downloaded, I want it to be downloaded automatically abbreviated to a fixed-size image. How should we revise it?

$sqltext = "Select Id,titlepic from {$dbtbpre}_article where titlepic like ' http://% ' ORDER by ID limit 1";    $r = $empire->fetch1 ($sqltext); if ($r) {$path =ecms_path. "        Uploads\\pic\\ ";        $yname = $path. basename ($r [titlepic]);        $filename = '/uploads/pic/'. basename ($r [titlepic]); if (file_exists ($yname) &&filesize ($yname) >0) {echo ($yname. ") already exists
"); File exists//exit (' s: '. FileSize ($yname)); } else {echo ($yname. ")
Down: ". $r [Titlepic]); $string =readfiletext ($r [titlepic]); Writefiletext_n ($yname, $string); Sleep (1); } $sqltext = "Update {$dbtbpre}_article set titlepic= ' $filename ' where id= ' $r [id] '"; Echo ('
'. $sqltext); $empire->query ($sqltext); Sleep (1); Echo "; } else {//echo " "; echo "Done"; } db_close (); $empire =null;

Reply content:

This PHP was originally to the titlepic in the chain image automatically downloaded, I want it to be downloaded automatically abbreviated to a fixed-size image. How should we revise it?

$sqltext = "Select Id,titlepic from {$dbtbpre}_article where titlepic like ' http://% ' ORDER by ID limit 1";    $r = $empire->fetch1 ($sqltext); if ($r) {$path =ecms_path. "        Uploads\\pic\\ ";        $yname = $path. basename ($r [titlepic]);        $filename = '/uploads/pic/'. basename ($r [titlepic]); if (file_exists ($yname) &&filesize ($yname) >0) {echo ($yname. ") already exists
"); File exists//exit (' s: '. FileSize ($yname)); } else {echo ($yname. ")
Down: ". $r [Titlepic]); $string =readfiletext ($r [titlepic]); Writefiletext_n ($yname, $string); Sleep (1); } $sqltext = "Update {$dbtbpre}_article set titlepic= ' $filename ' where id= ' $r [id] '"; Echo ('
'. $sqltext); $empire->query ($sqltext); Sleep (1); Echo "; } else {//echo " "; echo "Done"; } db_close (); $empire =null;

This is not an imperial CMS, your needs should be to save the remote picture at the same time automatically cut, then write a function added to writefiletext_n inside the line. As for how to crop the picture Google, you can directly use imagecopyresampled, or installed ImageMagick better, this than the GD class library.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.