Modify image file name parameters

Source: Internet
Author: User
Find a parameter to modify the image file name. find a CURL to save the remote image to the local server. the following code is a CURL to get the image and save the image parameters. The younger brother is not familiar with php. The answer to this question is, for example, "tp?@fopen('123.jpg', 'a}}calculate a parameter for modifying the image file name in this 123.jpg file.
Find a CURL to save the remote image to the local server.
The following code uses a CURL to obtain the image and save the image parameters. The younger brother is not familiar with php.
The problem to be solved now is how to $ tp = @fopen('123.jpg ', 'a); change this 123.jpg parameter to a file named after time
$ Url = 'http: // app.qlogo.cn/mbloghead/6e033128b37c1223af52/180.jpg ';
$ Curl = curl_init ($ url );
$ M = date ('y, m, dday', time () + (60*60*8 ));
Curl_setopt ($ curl, CURLOPT_REFERER, 'http: // app.qlogo.cn ');
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
// Whether the content is displayed
$ ImageData = curl_exec ($ curl); curl_close ($ curl );
// Save the image
$ Tp = @fopen('123.jpg ', 'a );
Fwrite ($ tp, $ imageData );
Fclose ($ tp );
?>

------ Solution --------------------
$ Url = 'http: // app.qlogo.cn/mbloghead/6e033128b37c1223af52/180.jpg ';
$ Curl = curl_init ($ url );
$ M = date ('ymdhis '). ". jpg ";
Curl_setopt ($ curl, CURLOPT_REFERER, 'http: // app.qlogo.cn ');
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
// Whether the content is displayed
$ ImageData = curl_exec ($ curl); curl_close ($ curl );
// Save the image
$ Tp = @ fopen ($ m, 'A ');
Fwrite ($ tp, $ imageData );
Fclose ($ tp );
?>

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.