I have an array of file upload inputs, When I upload files in each and submit, the files get uploaded adequately, and in the media table, teach gets inserted with the correct file name, file path etc except the file_description field that saves same value for all.
Below is my code:
//Save the added array of supporting scanned documents, if available//
if($request->hasfile('scan_copy1'))
{
$x = 0;
foreach($request->file('scan_copy1') as $copy1)
{
$x=$x+1;
$name=$copy1->getClientOriginalName();
list($nName,$nExt) = explode('.',$name);
$scanCopy1 = Auth::user()->id.'_'.time() . '_' . str_replace(' ', '_', $name);
$client->addMediaFromRequest('scan_copy1')->withCustomProperties(['mime-type' => 'image/jpeg'])->preservingOriginal()->usingName($nName)->usingFileName($scanCopy1)->toMediaCollection(User::$media_collection_main_scan.$x);
}
}