如何使用 php 从 url 保存文件


How to save a file from a url with php

如何使用变量$id=56将"示例.mp4"从$url="http://videos.com/example.mp4"保存为"56.mp4"以/videos

mkdir('/videos');

file_put_contents("/videos/" . ((string) $id) . ".mp4", file_get_contents($url));

文档:

http://php.net/manual/en/function.file-get-contents.php

http://php.net/manual/en/function.file-put-contents.php