Save remote img-file to server, with php

后端 未结 2 676
礼貌的吻别
礼貌的吻别 2021-02-05 17:23

I want to save a remote img-file to my server, but I don\'t know how to do.

The image url is http://img.youtube.com/vi/Rz8KW4Tveps/1.jpg and 1.jpg

2条回答
  •  抹茶落季
    2021-02-05 17:42

    If the URL stream wrappers are allowed, you can do it in 1 line rather than having to load it into a var:

    copy('http://img.youtube.com/vi/Rz8KW4Tveps/1.jpg', 'imgfolder/imgID.jpg');
    

    This is much less likely to cause a problem with PHP running out of memory.

提交回复
热议问题