Reputation: 1
I tried to upload file from a pc to my Laravel application and store to XAMPP
server. Unfortunately, every time when I want to check the file extension using $request->file
it always return me null.
But when I tried to debug I have seen that file image name that I uploaded from my system.
Here is code from front end:
<form action="{{action('CompaniesSettingController@update', $edit_info->id)}}" method="post",enctype="multipart/form-data">
<div class="p-image">
<i class="fa fa-camera upload-button"></i>
<input class="file-upload" name="company_profile" type="file" id="" accept="image/*"/>
</div>
Here Controller code:
dd($request->all());
$filenameWithExt = $request->file('company_profile')->getClientOriginalName();
Here is what I got from dd
array:12 [▼
"company_profile" => "myimage.jpg"
"name" => "App Name"
"email" => "[email protected]"
"phone_number" => "12345678"
"company_overview" => "dfsa"
"mission" => "dfs"
"working_evn" => "fgsd"
"company_ach" => "dfsgdfs"
"facebook" => "dfsg"
"linkedin" => "dsf"
"website" => "sdfsfdg"
]
As you can see the file that I have uploaded with named "company_profile" => "myimage.jpg"
. So, I want to get that image name but it return null and also that file image should be stored in my application and file name I will store in database.
Upvotes: 0
Views: 5572
Reputation: 1981
Remove the comma after the method="post"
attribute and add space.
Change this line:
<form action="{{action('CompaniesSettingController@update', $edit_info->id)}}" method="post",enctype="multipart/form-data">
to
<form action="{{action('CompaniesSettingController@update', $edit_info->id)}}" method="post" enctype="multipart/form-data">
And then check the dd($request->all())
to ensure that it is not the string against company_profile.
Upvotes: 1