Naor Naftali Naor Naftali - 4 months ago 71x
PHP Question

How to upload big files via Storage-ftp in Laravel 5.1

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));
$error_no = curl_errno($ch);

Work perfect! Better then Storage option of laravel.