Intervention Image: Save image directly from an url with original file name and ext?

前端 未结 3 740
悲&欢浪女
悲&欢浪女 2020-12-14 19:44

How to get the filename, when taking image from a remote server? And how to save with original size and filename?

// Take remote image
$img = Image::make(\'ht         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 19:58

    First Create new folder inside public folder called images , and execute the below code to download image from url and save it inside public\images folder

            $url = 'http://example.com/image.png';
            $img = public_path('images') . '\\test.png';
            file_put_contents($img, file_get_contents($url));
        
    

提交回复
热议问题