P
P
prozrost2017-02-15 14:34:10
Yii
prozrost, 2017-02-15 14:34:10

How to implement Upload image button in yii2?

The question is, there should be an "Add image" button, it is in the form. There are 5 thumbnails of these images that are filled with divs with a gray background, how to make it so that when you click on the button they are saved to those images?
I want to do like here
68234d2c323d485eaf5a2703f32dcb5e.PNG

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Maxim Fedorov, 2017-02-15
@qonand

Make your own widget that will send the selected file to the server and create and upload a thumbnail using javascript

D
Dmitry, 2017-02-15
@slo_nik

Good afternoon.
If you do not want to do it yourself, from scratch, then look here , maybe you will be lucky and you will find a package that will suit you 100%.
If not, then in the same place, you can take something similar and modify it to fit your needs.
ps Although Maxim Fedorov advises business.

E
Evgeny Bukharev, 2017-02-15
@evgenybuckharev

In fact, there are several options:
1. Write functionality for ajax sending and saving a file to the server, and after the action is completed, update image previews on the client
2. Modern browsers support the functionality for displaying images when adding them to an input file without uploading files to the server, this is how many image croppers work, the image itself will be uploaded to the server immediately after submitting the form

V
Vladimir, 2017-02-16
@ipdesign

Look at this module:
https://github.com/CostaRico/yii2-images/
It is just for this functionality

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question