• 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

Webscraping Symfony/Panther: Can't get HTML

Execute only one time and then wait set period of time before executing again

Laravel: Create morphs() relationship nullable

Generate random username based on full name php

Cache clear probem in Larave

Store multiple fields in JSON column (Nova CMS)

Laravel Route issues with Route order in web.php

Sagepay Error The Vendor failed to provide a RedirectionURL

How to KeyBy where multiple items have the same key

How to write PHP in XSLT

Laravel PHP: multiple project run at the same time [closed]

Laravel Model save() & update() Not Saving

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

generating a random code in php?

retrieve data from database using session

About Contact Privacy policy Terms and conditions