A
A
Alex Kyznetsov2017-07-05 09:52:02
CDN
Alex Kyznetsov, 2017-07-05 09:52:02

Transferring files from website to cdn storage?

Good afternoon
, there is a need to transfer the user's uploaded files to the file storage and return a link to view this file or files, but I do not quite understand how to do this, can anyone come across a similar issue, share information on how best to implement it?
to cdn access by login password and address (FTP/SFTP)/
Thanks in advance for any information

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima, 2017-07-05
@360157

Let's say uploads is the root folder on ftp. Then you can do this:

$file = $request->file('file'); // Файл из формы
$url = 'http://adress-ftp.com/uploads/' . $file->getClientOriginalName(); // Cсылка по которой будет доступен загруженный файл
Storage::disk('ftp')->put('uploads/' .  $file->getClientOriginalName(), $file);

And don't forget to include the Storage facade in the controller where the file will be uploaded.
use Illuminate\Support\Facades\Storage;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question