Image upload in an iframe using AJAX

Asked

Viewed 107 times

1

I tried to upload an image via AJAX using iframe, but I have no idea how to rewrite the image returned from the function after upload, follow the code:

<form target="frame" action="/painel/empresa/upload" method="post" enctype="multipart/form-data" name="formulario" id="formulario">

<input name="file" type="file"/>

<input type="submit" name="go" value="enviarrrr">

JS:

$(document).ready( function() { 
    $('input').change(function () {

    $('#formulario').submit();
    });

    $.getJSON('/echo/jsonp/?callback=?', function(e, progress) {

    });
  }
);

PHP:

public function upload(Request $request) {

    $data = $request->all();

    $teste = $data['file'];

    $nome = $teste->getClientOriginalName();



    return $nome;
}

Currently it returns only the name of the image inside the iframe, how can I render this image?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.