从文本文件中的 url 从服务器到服务器传输文件

Transfer files from server to server from urls in a text file

您好,我想将 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 都应屏蔽文件名和扩展名。 有人可以帮忙吗

这是一个非常简单的示例,您可以如何执行此操作。

    $remoteFileUrls = [
        'File 1' => 'http://origin-server-url/files.mp4',
        'File 2' => 'http://origin-server-url/files.mp4',
        'File 3' => 'http://origin-server-url/files.mp4',
        'File 4' => 'http://origin-server-url/files.mp4'
    ];

    $localFileUrls = [
        'File 1' => 'files.mp4',
        'File 2' => 'files.mp4',
        'File 3' => 'files.mp4',
        'File 4' => 'files.mp4'
    ];

    foreach($remoteFileUrls as $key => $remoteUrl){
        /* Copy the file from source url to server */
        $copy = copy( $remoteUrl, $localFileUrls[$key] );

        /* Add notice for success/failure */
        if( $copy ) {
            echo "Success\n";
        }
        else{
            echo "Failed\n";
        }
    }