2017-02-11 10 views
0

ich folgende Form habenHochladen von Bildern in Schleife

<form method="POST" action="{{url('/add-photo')}}" class="form-horizontal form-label-left" enctype="multipart/form-data" id="form-photo"> 
        <input name="_token" type="hidden" value="{!! csrf_token() !!}" /> 


    <div class="item form-group"> 
          <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Gallery Title<span class="required">*</span> </label> 
          <div class="col-md-6 col-sm-6 col-xs-12"> 
          <input id="gallery_title" name="gallery[0][photo_title]" class="form-control col-md-7 col-xs-12 album_name" placeholder="Gallery Title" required="required" type="text">    
          </div> 
            <div class="col-md-3 col-sm-6 col-xs-12"> 
          <button type="button" class="btn btn-primary" id="add_new_gallery"> 
          <span class="glyphicon glyphicon-plus" aria-hidden="true"> 
          </span>add</button> 

         </div> 
          </div> 
        <div class="item form-group"> 
       <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Gallery Image<span class="required">*</span> </label> 
       <div class="col-md-6 col-sm-6 col-xs-12"> 
         <input type="file" id="input02 gallery_image" class="form-control gallery_image" name="gallery[0][photo_image]"> 
       </div> 
      </div>  
       <div class="item form-group"> 
       <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Gallery Description<span class="required">*</span> </label> 
       <div class="col-md-6 col-sm-6 col-xs-12"> 

        <textarea class="resizable_textarea form-control profile_address" id="profile_address" name="gallery[0][photo_description]" rows="8" placeholder="Tore text courtes"></textarea> 

       </div> 
       </div> 



      <div class="ln_solid"></div> 
           <div id="dynamic_gallery_data"></div> 
      <div class="form-group"> 
      <div class="col-md-6 col-md-offset-3"> 
       <button type="submit" class="btn btn-primary">Cancel</button> 
       <button id="submit-photo" type="submit" class="btn btn-success">Save</button> 
      </div> 
      </div> 
     </form> 

in Controller Ich habe

gedruckt
$gallery = $request->get('gallery'); 
    print_r($gallery); 

Ich erhalte nur Titel und Beschreibung.

Array 
(
    [0] => Array 
     (
      [photo_title] => sfsafsa 
      [photo_description] => asfa 
     ) 

) 

Kann jemand mir helfen, wie auch bin dynamisch Felder i innerhalb array.because Dateinamen erhalten bilden

Antwort

1

Versuchen:

$image = $request->file('gallery[0][photo_image]'); //UploadedFile object 
$imageFileName = $image->getClientOriginalName() . "." 
        . $image->getClientOriginalExtension(); 
+0

@ Paras.Thanks aber ich habe assoziatives Array bedeutet Galerie [0] [Foto_Bild], Galerie [1] [Foto_Bild] usw. – iCoders

+0

wenn ich $ Image = $ Anfrage-> Datei ('Galerie'); dann bekomme ich alle Dateien, aber ich bekomme keine weiteren Details wie Titelbeschreibung usw. – iCoders

+0

Ich denke '$ request-> file ('gallery')' wird Ihnen ein Array von Dateien geben und die Schlüssel dieses Arrays werden den Schlüsseln der $ Anfrage entsprechen -> get ('gallery') 'array, damit Sie jede Datei mit dem Titel und der Beschreibung verknüpfen können. Hoffe das hilft! – Paras

Verwandte Themen