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?
PHP files are on the server;
The image url is known;
Reply content:
How can I write the code to store images on the server in php?
PHP files are on the server;
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_FILE
The 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.