• 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/ PHP: Order By Alphabetical with numbers in order [duplicate]

Add and update products to session cart in Laravel

Inserting Country Selection into MySQL PHP [duplicate]

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

Check If array is null or not in php

Prestashop cUrl Login

Why rand() every time I refresh the page?

Pass a select with mysqli_fetch_row to a table

PHP - installing Xdebug on Mac with XAMPP (Unix File)

could not find driver Debian SQL Server PHP

Apply session id from request header

Get number of working days between two dates in PHP [duplicate]

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Limit of log line written to Apache Errorlog from mod php error_log

Symfony - "framework.test" config is not set to true

About Contact Privacy policy Terms and conditions