
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 the random value form a specific column in laravel ?
- Drop foreign key column in Laravel using migration
- Laravel route redirect not working
- Target class [HomeController] does not exist
- How to get list of all views file in laravel
- Post model with title and body in laravel 8
- How to call model in blade laravel
- Save or update pivot table data with additional column in Laravel
- Target class [admin] does not exist.
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- How to create belongstomany relation using custom name on custom pivot table
- How to create projects method with belongstomany relationship in user model
- How to create pivot table in laravel using migration
- Class "App\Http\Controllers\Auth\Verified" not found
- Retain selected value of select box in Laravel
- How to pass two variables in HREF in laravel
- Get current month records in laravel 7/8
- How to check records exist in loaded relationship in Laravel blade view
- How to insert value to additional columns in pivot table in laravel
- Composer create project laravel/laravel example app
- RuntimeException You must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
- How to pass variable from controller to model in Laravel
- Pass variable from blade to controller Laravel
- How to add class to tr in table using foreach in laravel
- Undefined property: stdClass::$title