使用Laravel中的Storage功能将文件存储在子域/自定义文件夹中


Storing files in a subdomain/custom folder using the Storage function in Laravel

我正在尝试将文件上传到子域,托管在同一台服务器上,而Laravel应用程序托管在主域上。是否有任何方法可以使用子域的存储功能?或者类似的东西?

您可以使用FTP将文件从您的服务器传输到另一个服务器。

首先,接收方必须有ftp帐户。

第二,你可以使用下面的代码来传输你的文件[source]。

<?php
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
    echo "successfully uploaded $file'n";
} else {
    echo "There was a problem while uploading $file'n";
}
// close the connection
ftp_close($conn_id);
?>