• 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

Getting public posts of a random user from Facebook API

How to Display Data in Yajra Datatables Laravel 7?

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

Create tags in laravel post publishing

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

Adding the custom page with add_menu_page function on Wordpress

Required field only if another field has a value, must be empty otherwise

how to remove %20 in the url in php

Transpose csv file data [duplicate]

IlluminateDatabaseQueryException could not find driver [duplicate]

How to load Codeigniter 4 lang file into an array variable

Whats the point of running Laravel with the command 'php artisan serve'?

Display Link Title Instead of URL in XSL

Laravel query builder binding parameters more than once

Valet, Xdebug after reboot Big Sur not working

About Contact Privacy policy Terms and conditions