Download - php What is the process of saving images to the local mobile phone?
天蓬老师
天蓬老师 2017-06-23 09:11:42
0
4
917

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);
    }
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
習慣沉默

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

三叔

The correct answer upstairs is that downloading can be done without using the JS a tag

为情所困

Just link the file address directly in your browser

学习ing

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');

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template