• 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

Form repeater send wrong data with last element in Laravel

Laravel websockets AWS EC2 - Connection failed

How to display MySQL table using php and edit it in a web browser

Dropdown with current value from Mysql

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

possible options to create pdf file using html elements to generate invoice in php and codeigniter

Unable to guess the mime type as no guessers are available Laravel 5.2

Navigation idle on content download

How in Laravel run JavaScript code stored in php variable?

zsh: command not found: php

Getting output of MS stored procedure on php call

Laravel: Create morphs() relationship nullable

XDebug not working in VScode for php debugging

Get all WooCommerce products within own plugin

Override default Auth routes in Laravel 7

About Contact Privacy policy Terms and conditions