0

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);
             
  }
}
Ola
  • 1
  • 3
  • You should be setting the same value for the ``file_description`` field !! – OMi Shah Oct 12 '22 at 08:40
  • @OMiShah I want the respective name of each file uploaded. For example, "Passport", if the uploaded image is "passport.jpg" – Ola Oct 12 '22 at 08:43
  • name or file description !!! Please be clear. – OMi Shah Oct 12 '22 at 08:45
  • @OMiShah the field is "name", I am the one who sees that as the file description – Ola Oct 12 '22 at 08:49
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 12 '22 at 10:18

0 Answers0