S
S
sowich2013-03-25 21:21:00
JavaScript
sowich, 2013-03-25 21:21:00

Upload files in jquery?

Guys, the question is probably already beaten, but something does not come across a solution at the end of the working day.
Probably everyone knows the extension: https://github.com/blueimp/jQuery-File-Upload

It has a great interpretation for Yii. Everything is loading fine, the question is this.

Is it possible to somehow upload a photo in the template that we see during the upload (after the page refresh)?

Like uploaded photos, saved the news, logged in a day later and see the news fields and at the bottom of the photo in the template of this plugin + the ability to upload additional material.

I can’t figure out something in any way, or is it not provided for in this plugin at all?

Thank you!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
sowich, 2013-03-25
@sowich

If anyone needs:

$('#fileupload').each(function () {
            var that = this;
            $.getJSON('/news/t', function (result) {
                if (result && result.length) {
                    $(that).fileupload('option', 'done')
                        .call(that, null, {result: result});
                }
            });
        });

Issue resolved.

T
tamtakoe, 2013-03-30
@tamtakoe

May help: github.com/tamtakoe/photoalbum/tree/master/jQueryFileUploadDemo
demo: tamtakoe.ru/photoalbum/

A
Alexander Borisovich, 2013-03-25
@Alexufo

Tried to code this uploader for YII. The programmer sat with me for a day. In the evening he said:
Well, fuck it, if the apploader's API doesn't allow something, then it's easier to write your own loader than so many castes.
The next day I made my bootloader.
Well, let's think that the photo preview during upload is a file api from html5.
To see it there after a refresh in a day, then only by selecting the file from the computer again, because this is a browser feature.
So generate previews after loading on the server and return them back. For what you want, as I understand it, is to intervene in fileapi with a script, and this is impossible.

S
sowich, 2013-03-25
@sowich

Perhaps I did not clearly formulate the problem, but I think that the issue is solved.
We do apload, writes to the database. Refresh the page, we can easily get photos of the news in json or whatever, and stupidly need to push it all back into the view. I smoke API, it should be like that, is it really a crutch to sculpt?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question