Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

284
Visualizações
Saving images uploaded using ImagesLoader

I am trying to wire up the ImagesLoader plugin, which allows uploading multiple images. It has a nice drag-n-drop UI but I just can't figure out how to get the images that were uploaded. I cannot find any documentation.

Link to the plugin page: ImagesLoader

Here is the javascript from the demo:

  <script type="text/javascript">

// Ready
$(document).ready(function () {

  // Create image loader plugin
  var imagesloader = $('[data-type=imagesloader]').imagesloader({
    minSelect: 3
   ,imagesToLoad: [{"Url":"./img/Nespresso001.jpg","Name":"Nespresso001"},{"Url":"./img/Nespresso002.jpg","Name":"Nespresso002"}]
  });

  //Form
  $frm = $('#frm');

  // Form submit
  $frm.submit(function (e) {

    var $form = $(this);

    var files = imagesloader.data('format.imagesloader').AttachmentArray;
    var il = imagesloader.data('format.imagesloader');

    if (il.CheckValidity())
      alert('Upload ' + files.length + ' files');        

    e.preventDefault();
    e.stopPropagation();
  });

});

The images are saved in the object "files". Here is a screen shot of the contents from the inspector:

Inspector

I tried converting to json and posting, but that only generates an error.

            $.ajax({
                url: 'process-images.php',
                type: 'POST',
                data: JSON.stringify(files),
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                cache: false,
                error: function() {alert("ERROR");},
                success: function() {alert("OK");}
            });

The rest of the code works just like the demo. Looks like everything needed for the uploaded images is stored in "files". I just need to get the data back to php and I can pull it apart from there. But right now, the original submit code just dies or my addition aborts with an error.

THANKS!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I hope it is not too late to answer. You just need to loop through the base64 encoded image object, decoding and saving each image to the disk.

// Sample code    
foreach(json_decode($request->input('files')) as $file) {
   $name = $file->FileName 
   $imagePath = storage_path('app/public/images/');
   file_put_contents($imagePath.$name, base64_decode($file->Base64));
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda