How Can I Upload Profile Pic In Laravel?
In add employee form I have to upload profile pic? is this code is valid?? will anyone help me to modify the code?
This Code Is In My Controller File
$employee = new User(); $file = $request->file('file'); $name = time() . $file->getClientOriginalName(); $file->move('uploads/images', $ $employee->file = $file; $employee->save();
This IS Code Of My view file
<div class="col-md-6"> <div class="form-group"> <label for="photo">Profile Picture :<span class="danger">*</span> </label> <input type="file" class="form-control" id="file" name="file"> </div> </div>
Issue is that everything work properly but in my collection of mongodb file isn't store. it upload in folder, but not in database.
You should change
$file variable with
$employee->file = $name; // $file may contain file object $employee->save();
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?