0

I have an input that allows people to upload images, then I use DirectoryIterator to display them, below is the code:

<div class=".content">
   <?php
   foreach ( new DirectoryIterator as $value ) {
      ?>
      <img src="<?php $value -> getFilename ?>">
      <?php
   }
   ?>
</div>

But after people uploaded the images, how do I only refresh the div .content and not the whole page with Ajax. ( I'm not interested in jQuery )

Like below is the example code for the input:

<form method="post" enctype="multipart/form-data">
   <input type="file" name="test">
   <input type="submit">
</form>

I have referred to this but it's too general and I have totally no idea how to implement it in my case.

yobebix932
  • 57
  • 4
  • "Refresh" if generally a page-level concept. What you are looking to do is to update the HTML in a specific region with new HTML. The solution is that you need to make a JS call (AJAX or fetch) to the server and ask for the new content. The latter is just an HTTP request which should be easy in PHP. The return could be JSON (or XML, etc.) or you could return the actual HTML for that area. – Chris Haas Dec 09 '22 at 14:33

0 Answers0