• 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 MVC execution flow

WordPress Subquery returns more than 1 row on SELECT

How to access a var with "-" in PHP [duplicate]

loop through an anchor id

Eloquent insert id with sequence next value

How to fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

Select option menu read from database and use it's values

Modify microseconds of a PHP DateTime object

How to run a shell as root from php (apache)

Prestashop webservice API creating cart rules

send email using gmail-api and google-api-php-client

Performance of foreach, array_map with lambda and array_map with static function

How do I Post to .txt document before form submits

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

How to fix bootstrap multiselect search data using ajax

About Contact Privacy policy Terms and conditions