如何在Laravel 5.1中通过Storage-ftp上传大文件

I'm trying to upload big file to ftp server with Laravel Storage function and it's keep give me the erorr

Out of memory (allocated 473432064) (tried to allocate 467402752 bytes)

I've tried to change the memory limit on php.ini and it still won't work, when I upload file to the server normally its work and the size dosent metter.

I've tried anything but nothing work. Again - I'm trying to upload via FTP.

One more question : there is a way to uplaod the file direct to the ftp server from the client? I see that the storage upload first to my server and then transfer to the second server...

Finally I solve the problem by using curl instead of Storage.

$ch = curl_init();
$localfile = $file->getRealPath();
$fp = fopen($localfile, 'r');
curl_setopt($ch, CURLOPT_URL, 'ftp://domain/' . $fileName);
curl_setopt($ch, CURLOPT_USERPWD, "user:pass");
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec($ch);
$error_no = curl_errno($ch);
curl_close($ch);

Work perfect! Better then Storage option of laravel.

It definately sounds like a PHP Limitation, raising the memory limit probably isn't the best way to do it though, that leads to nothing but hassle, trust me.

Best method i can think of from the top of my head is to use Envoy (the server script method not the deployment service) to put together an SSH task, that way your job is being executed outside of PHP so you're not subject to the same memory limitations. Your Envoy script (envoy.blade.php in your project root) would probably look something like this;

@servers(['your_server_name' => 'your.server.ip'])

@task('upload', ['on' => ['your_server_name']])
    // perform your FTP setup, login etc.
    put your_big_file.extension
@endtask

I've only got one of these set up for a deployment job which is called from Jenkins so i'm not sure if you can launch it from within Laravel, but i launch from the command line like this;

vendor/bin/envoy run myJobName

Like i said the only thing i can't quite remember is if you can run Envoy from within Laravel itself, and the docs seem a little hazy on it, Definately an option worth checking out though :)

https://laravel.com/docs/5.1/envoy