【发布时间】:2016-02-23 13:52:36
【问题描述】:
您好,我想将文件从保存在文本文件中的 url 从一台服务器传输到另一台服务器。我正在使用共享的 linux 主机。 目前,此代码适用于从单个 url 传输文件。但我想从一个文本文件中加载许多 url。
/* Source File URL */
$remote_file_url = 'http://origin-server-url/files.mp4';
/* New file name and path for this file */
$local_file = 'files.mp4';
/* Copy the file from source url to server */
$copy = copy( $remote_file_url, $local_file );
/* Add notice for success/failure */
if( !$copy ) {
echo "Doh! failed to copy $file...\n";
}
else{
echo "WOOT! success to copy $file...\n";
}
并且文件名和扩展名应该从每个 url 中屏蔽。 有人可以帮忙吗?
【问题讨论】:
-
你必须创建一个数组并使用foreach
-
你能告诉我怎么做吗
-
将文本文件中的每一行一一读取,然后解析。