@princeparaste If you’re uploading images in a HTML form, then you need to set the appropriate encoding type:
<form enctype="multipart/form-data">
This will then send the actual uploaded files, instead of just the names of the files.
Hi, I am trying to uploading image in a form and in controller i am sending in associative array. I am not able to get the images in controller .
My index.blade.php view file =>
<form>
<input type="file" name="comp_job[{{$job->id}}][img]" class="upload-job-img"
accept=".jpg">
<input type="text" class="form-control" name="comp_job[{{$job->id}}][name]"
value="{{ $job->job_title }}" placeholder="Enter Job Name" />
<textarea class="form-control" name="comp_job[{{$job->id}}][desc]"
rows="3">{{ $job->job_desc }}</textarea>
</form
My Controller =>
$files = $request->file('comp_job');
How to get the the uploaded image in controller and save it to public folder ? When i am trying to get from $request->file('comp_job'); its giving me null value.
I am using repeater fileds thats why input fields are like this.
I just want to save each img of comp_job array in public folder (array structure shown below) How to do it ?
array:13 [▼
"_token" => "B5zYZw8qcASzLcq0NckdJ2aizsHoREBJx1gXbbB5"
"comp_job" => array:4 [▼
0 => array:4 [▼
"img" => "approved-contract-documents-rubber-stamp-concept-73048177.jpg"
"id" => "eyJpdiI6IkZ6bVJBNU4zblVRd2xqdW85aFlDbUE9PSIsInZhbHVlIjoiMkRjTWFVVHkwbk90TmRsbHBSdjFiUT09IiwibWFjIjoiN2E2MjkxMWYwOTAzMDEwMDllY2Y5YmM5ODM4YzcyNjVhZjJjMjdmZDMxNTFj ▶"
"name" => "Idona Pickett"
"desc" => "Et et error distinct"
]
2 => array:4 [▼
"img" => "cool-profile-pictures2-291x300.jpg"
"id" => "eyJpdiI6Ijh3SFJxYVRkbHpUZFVVTXJqSjZnclE9PSIsInZhbHVlIjoiNC9YaG1kTVhaN3J5Ykorcld6SkYydz09IiwibWFjIjoiOTliNTYzMTNjZjk0OTAyZDI3NGYxYzQxNDY2MDE1ZWQ4ODQ1ZWQ0NzUzN2Yx ▶"
"name" => "Macey Ballard"
"desc" => "Qui minus atque dolo"
]
3 => array:4 [▼
"img" => "snooptDOG.jpg"
"id" => "eyJpdiI6Ikc1Y1U1eXNDcW1td0w5cFRka0tWd2c9PSIsInZhbHVlIjoiY2V6S2kveStjSHUvb2NrczVFd2NZUT09IiwibWFjIjoiZmRhZGU5ZDk2OGNjZTZlMzY2OGNjZWNjMjZkZTJlYmY1OGM1ZWNlNWIyZDNk ▶"
"name" => "Serina Dale"
"desc" => "Mollit in eu do odio"
]
4 => array:4 [▶]
@princeparaste If you’re uploading images in a HTML form, then you need to set the appropriate encoding type:
<form enctype="multipart/form-data">
This will then send the actual uploaded files, instead of just the names of the files.
Please or to participate in this conversation.