Php image storage to server

Source: Internet
Author: User
How can I write the code to store images on the server in php? Php files are on the server; image URLs are known; and images are stored on the server in php. How can I write the code?

  1. PHP files are on the server;

  2. The image url is known;

Reply content:

How can I write the code to store images on the server in php?

  1. PHP files are on the server;

  2. The image url is known;

The idea is to first obtain the image in the php code and store it on the server.

The code can be organized as follows:

$ Url = 'HTTP: // response = '/tmp/bear.jpg'; $ pic = file_get_contents ($ url); file_put_contents ($ img, $ pic );

You can also use cURL and setCURLOPT_FILEThe property is a local file.

One idea is to download the image from the url address to the local device and upload it to the remote server.

Direct copy

When writing php, the Image Upload obtains the local file address of the client. The local address is changed to a known url address, and a script is written to directly upload the file.

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.