Laravel upload file with original file name
Laravel upload file with original file name
Through the use of the programming language, we will work together to solve the "Laravel upload file with original file name" puzzle in this lesson.
Sometimes you have to upload the file in directory with the same (original) file name in Laravel. In that case you can get the file name of file with getClientOriginalName() and upload in directory.-
Upload file in directory with its original file name in laravel
$file = $request->file('avatar'); $fileName = $file->getClientOriginalName() $file->storeAs('avatars', $fileName);
This code snippet will upload the file with its original filename to directory. You can get the input file using $request->file('filename') with the file name attribute and upload the image with their original filename.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to get random string in Laravel
- Conditional validation in laravel
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- Recursive function example code PHP Laravel
- How to generate .env file for laravel?
- How to get the id of last record from collection object in laravel view
- How to include header file in laravel
- How to fetch single row data from database in laravel
- Laravel csrf token mismatch for ajax POST Request
- Extra Filter Query on Relationships in Laravel
- Laravel delete all rows older than 30 days
- How to call model in blade laravel
- Method Illuminate\Http\Request::validated does not exist
- Create a record if not exist in laravel
- Insert data with form validation using ajax in laravel
- How to add background image to div using Tailwindcss, Vite in Laravel Environment
- How to restore deleted records in laravel
- Route [password.request] not defined
- Return view from route Laravel
- Laravel 5.4 save data to database
- How to Run CRON Job on LIVE SERVER on Cpanel in Laravel Project
- How to implement toggleLike() method in Overtrue\LaravelLike laravel package
- How to add unique records in pivot columns of Laravel pivot table
- Create user in Laravel using tinker
- How to call Laravel route in jQuery