In general, I want to realize the output of the image after it is loaded on the page without reloading. At the moment I can display data about the file loaded or the text required. Can you tell me how to get the output of several images with JSON after downloading?
Js

$(function(){ $('#my_form').on('submit', function(e){ e.preventDefault(); var $that = $(this), formData = new FormData($that.get(0)); $.ajax({ url: $that.attr('action'), type: $that.attr('method'), contentType: false, processData: false, data: formData, dataType: 'json', success: function(json){ if(json){ $that.replaceWith(json); } } }); }); });<br> 

Php

 if(isset($_POST['fio'],$_FILES['avatar'])){ $req = false; ob_start(); echo '<pre>'; echo 'Имя пользователя: <strong>' , $_POST['fio'] , '</strong><br>Данные загруженного файла:<br>'; print_r($_FILES['avatar']); echo '</pre>'; $req = ob_get_contents(); ob_end_clean(); echo json_encode($req); exit; } 
  • return links to new files, and drop them in img src="ссылка" - Vasily Barbashev
  • @ Vasily Barbashev, did not quite understand. Could you write in more detail how I can display images. - Eliot
  • How do you upload files on the server? Can you get links to them? And yet, the response from the server should not contain too much, and you still have echo output before echo json_encode($req) - Vasily Barbashev

0