• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Using spatie/media-library, how to rename a collection of uploaded files?

phplaravellaravel-medialibrary


PHP Snippet 1:

$request->file('photo')->extension()

PHP Snippet 2:

        $newFileName = Str::random(20) .'.'.$request->file('photo')->extension();

PHP Snippet 3:

            $item->addMedia($request->photo)->usingFileName($newFileName)->toMediaCollection('photo');

Related Snippets

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Laravel Unknown Column 'updated_at'

AJAX call fails with SyntaxError: Unexpected end of JSON input

Jquery DataTables: Data not displaying in table via Ajax

Laravel Livewire: jQuery not working in child component loaded via @if statement

Xdebug can't connect back to Docker host

Error converting docx to pdf using Unoconv

jQuery Ajax Post with data

PHPExcel How to set conditional formatting to change cell background color based on cells values

Add bold text and line break into Laravel Notification Email

How to pass data to all views in Laravel 5?

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

Pass a select with mysqli_fetch_row to a table

How to change the app environment at run time?

How to generate QR CODE for dynamic generating link and logo using Simple QrCode in laravel?

About Contact Privacy policy Terms and conditions