O
O
on_click2021-08-19 04:26:00
Laravel
on_click, 2021-08-19 04:26:00

How to upload a large file to the server using a link?

Greetings!

Please tell me, is there any simple way in laravel to copy a large file to the server from an external resource by url?

I found this package - https://github.com/Naxon/laravel-url-uploaded-file
But for some reason files larger than ~2.5gb are not uploaded

in php.ini
upload_max_filesize=4000M
post_max_size=4000M
max_execution_time=3600

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-08-19
@on_click

The first is to check the file system, the second is to check your php assembly, in older versions of php there was such a phenomenon on 32-bit assemblies, well, I would show your import code itself.
If I find it, I will throw my import here

$dir = 'uploads';
$newFile = basename(rtrim($url, '/'));
$uploadFile = new SplFileObject($url, 'rb');

$file = new SplFileObject($dir . DIRECTORY_SEPARATOR . $newFile, 'w');
$file->setFlags(SplFileObject::SKIP_EMPTY);
if ($file->flock(LOCK_EX)) {
    $file->ftruncate(0);
    while (!$uploadFile->eof()) {
        $file->fwrite($uploadFile->fgets());
    }
}
$file->flock(LOCK_UN);

You may also need to look at the server settings

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question