
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 insert multiple rows in mysql using loop in laravel?
- How to access the nth object from Laravel collection object ?
- How to check email is valid or not in Laravel
- Laravel append URI in route
- How to Get records between two dates in Laravel
- Create project factory and seed data in laravel
- How to customize pagination view in laravel
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- How to get column names from table in Laravel
- Post model with title and body in laravel 8
- How to add columns in existing table using migration in laravel
- Datetime field in Laravel migration
- Get count of filter data, while return a small set of records
- Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
- Ajax GET request in laravel
- Pass value from controller to model in laravel
- Call to undefined method Illuminate\Support\Facades\Request::all()
- Composer\Exception\NoSslException
- Display data in table using foreach in Laravel
- Validation errors for multiple forms on same page Laravel
- Redirect to previous page or url in laravel
- Retrieve count of nested relationship data in Laravel
- Laravel create multiple records in Pivot table
- How to send ID to another page in Laravel
- Insert current date time in a column using Laravel