• 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

How to get multiple values with same key from an array PHP

How do I upload a laravel project on cPanel shared hosting?

The sum of the user's points

Laravel 5 issue with wherePivot

Explode not working properly with dash

CodeIgniter 4: Like and Dislike Functionality

How to edit Records using CodeIgniter

Laravel dosen't connect with Oracle

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

Minimum order amount except for specific shipping method in WooCommerce

How can I create a Download Page with post php method?

Toggle between a textbox and a select using PHP

PHP: How to raise number to (tiny) fractional exponent?

Shopify password update using Shopify API

Limit login attempts in Laravel 5.7

About Contact Privacy policy Terms and conditions