Download File to server from URL

后端 未结 12 1417
旧巷少年郎
旧巷少年郎 2020-11-22 04:05

Well, this one seems quite simple, and it is. All you have to do to download a file to your server is:

file_put_contents(\"Tmpfile.zip\", file_get_contents(\         


        
12条回答
  •  不要未来只要你来
    2020-11-22 04:25

    Use a simple method in php copy()

    copy($source_url, $local_path_with_file_name);
    

    Note: if the destination file already exists, it will be overwritten

    PHP copy() Function

    Note: You need to set permission 777 for the destination folder. Use this method when you are downloading to your local machine.

    Special Note: 777 is a permission in Unix based system with full read/write/execute permission to owner, group and everyone. In general we give this permission to assets which are not much needed to be hidden from public on a web server. Example: images folder.

提交回复
热议问题