Save image to server from a URL

前端 未结 1 906
-上瘾入骨i
-上瘾入骨i 2021-01-23 17:47

I\'ve built a mini-content management system with CKEditor. The user has the ability to paste an image URL from another website. Is there a way to to get all image URLs when the

1条回答
  •  深忆病人
    2021-01-23 18:32

    If you have PHP5 and the HTTP stream wrapper enabled on your server, it's incredibly simple to copy it to a local file:

    copy('http://somedomain.com/file.jpeg', '/tmp/file.jpeg');

    This will take care of any pipelining etc. that's needed. If you need to provide some HTTP parameters there is a third 'stream context' parameter you can provide.

    0 讨论(0)
提交回复
热议问题