• 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

laravel automatically deletes server.php on php artisan serve

How to get Laravel's CSRF Token from Another Website?

Laravel - How to properly generate unique slugs from article titles?

How in Laravel run JavaScript code stored in php variable?

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

Message: Set sys_temp_dir in your php.ini after installed composer

How to create custom authentication in laravel 8?

Sagepay Error The Vendor failed to provide a RedirectionURL

Creating Combinations of Elements

Attempt to read property "view" on null when sending password reset email

Star and Half Star Rating in Laravel

Laravel relationship belongsToMany with composite primary keys

how to remove %20 in the url in php

PHP web3 ERC20 token function call

strpos(): Argument #1 ($haystack) must be of type string, array given

About Contact Privacy policy Terms and conditions