Add watermark to the picture on the mobile phone and then save it locally on the phone
Why are the downloads you see now all downloaded to the server? Can't they be downloaded to the local phone?
The download code refers to this
public function downloadImage($url, $path='images/')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
$file = curl_exec($ch);
curl_close($ch);
$this->saveAsImage($url, $file, $path);
}
private function saveAsImage($url, $file, $path)
{
$filename = pathinfo($url, PATHINFO_BASENAME);
$resource = fopen($path . $filename, 'a');
fwrite($resource, $file);
fclose($resource);
}
習慣沉默2017-06-23 09:13:42
DownloadImg downloads remote images to the local server. If you need to save the image locally on your mobile phone, this can only be achieved by browser and js. PHP runs on the server side
三叔2017-06-23 09:13:42
The correct answer upstairs is that downloading can be done without using the JS a tag
学习ing2017-06-23 09:13:42
In response to your question, the answer is: No.
This code of yours saves remote files to the server where PHP is located through http.
To download to your mobile phone, refer to http file download.
header('Content-Disposition: attachment; filename=xxxxx');
readfile('File on PHP server');