cezi7's avatar
Level 1

Sortable images with jQuery ui-sortable and Laravel

Hello. I want to insert multiple images and before upload them I want to sort them so the user can choice the first image. This is my jquery:

$( "#sortable" ).sortable({ update:function(event, ui) { event.preventDefault(); $.ajax({ type:'POST', url:'{{ route('vehiculos.store') }}', data: $(this).sortable('serialize'), success:function(data){ alert(data.success); }, error : function() { alert('error...'); } }); } });

And my Controller where I upload the images:

if($request->hasFile('imagenes')){

            foreach($files as $file){
                
                $filename = $file->getClientOriginalName();     
                
                $vehiculo->imagenes .= $file->storeAs($folder, $filename) ."@";
                                
            }                           
        }

I don't know what else to put in my controller. When I try to sort the images I recieve this error via console: 422(Unprocessable Entity). Thank you.

0 likes
0 replies

Please or to participate in this conversation.