php - Laravel ftp upload with tus
Get the solution ↓↓↓I need to upload large files throguh ftp with tus, so the file is uploading as little parts.
It is possible to upload tu s3 with tus through this packages, but unfortunately they didnt support ftp, and I cannot find any ftp tus package or solution on the web. Does anybody has a hint or some advice? https://github.com/rafaeltovar/php-tus-aws-s3 https://github.com/ankitpokhrel/tus-php
Answer
Solution:
I managed to do it with php chunck upload from this article: https://artisansweb.net/how-to-implement-chunk-upload-in-php/
the source code for chunk upload in php:
$tmpfile = storage_path(PATH);
$orig_file_size = filesize($tmpfile);
$chunk_size = 256; // chunk in bytes
$upload_start = 0;
$handle = fopen($tmpfile, "rb");
$fp = fopen('ftp://USERNAME:PASSWORD@HOST:21//TARGETDIR/FILENAME', 'w');
while($upload_start < $orig_file_size) {
$contents = fread($handle, $chunk_size);
fwrite($fp, $contents);
$upload_start += strlen($contents);
fseek($handle, $upload_start);
}
fclose($handle);
fclose($fp);
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: trying to access array offset on value of type null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.