P
P
prozrost2017-03-12 20:50:41
Yii
prozrost, 2017-03-12 20:50:41

Adding previews for uploaded images using ajax, is it possible?

I want to make a type of preview for uploaded pictures. There is a field in the view for uploading images, it looks like this:

<?= $form->field($images, 'imagesFiles[]')->fileInput(['multiple' => true, 'accept' => 'image/*','id'=>'gallery-photo-add'])->label(false) ?>

I get these pictures in the controller using:
$images->imagesFiles = UploadedFile::getInstances($images,'imagesFiles');

And now I want to make a preview for these pictures using ajax (without reloading the page), maybe someone did something similar. Pictures should be from 1 to 5. Well, pictures should be added using ajax methods and removed too using another ajax method. How to add pictures from and find out which ones to delete?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2017-03-12
@Stalker_RED

So do you want a preview, or a display of already uploaded ones?
You can preview without ajax https://jsfiddle.net/kj67cmuw/2/

A
Anton, 2017-03-12
@karminski

Don't you know?
https://blueimp.github.io/jQuery-File-Upload/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question