N
N
Nikolay Matyushkin2018-03-11 17:46:53
PHP
Nikolay Matyushkin, 2018-03-11 17:46:53

How to display uploaded images on the page as they are uploaded to the server?

Hello. Actually the question is: there is a form for uploading images to the server (to a specified folder). It is necessary that when loading an image on the page, it immediately appears at the bottom. The next image follows it, and so on. The maximum that I could do was display one image that had just been loaded. the next time it was loaded, it changed to the newly loaded image.
Tell me what can be done? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2018-03-11
@sidni

Just recently Which library should I use to load images and videos?
The nuance of the plugin loads files instantly, so you need to take care of cleaning the directory

E
Evgeny Zaharov, 2018-03-11
@drymind404

Do you want to do this without js?) You need AJAX. When submitting the form, you intercept the event, send an ajax request with the data you need (images can be transmitted through the FormData object), accept all this on the server, do the necessary actions, and send a response (echo) from there with the desired header. For example, you can send an html text containing a new image list element. And finally, add this element to the end of the list using the success property of the ajax request (well, or display an error using the error property)
If you want images to appear on the page in turn, you can send an ajax request for each uploaded file, but then may be loaded out of sequence due to different sizes. To keep everything in order, you need to apply more complex mechanics.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question