plupload not working in wordpress theme files
Posted
by
Kedar B
on Stack Overflow
See other posts from Stack Overflow
or by Kedar B
Published on 2014-08-21T07:40:36Z
Indexed on
2014/08/21
10:20 UTC
Read the original article
Hit count: 285
This is my code for image upload....
<a id="aaiu-uploader" class="aaiu_button" href="#"><?php _e('*Select Images
(mandatory)','wpestate');?></a>
<input type="hidden" name="attachid" id="attachid" value="<?php
echo $attachid;?>">
<input type="hidden" name="attachthumb" id="attachthumb" value="<?
php echo $thumbid;?>">
i want upload functionality more than one time in single page in wordpress.i have add js code for that same as first upload block but its not working.
This is js code for image upload....
jQuery(document).ready(function($) {
"use strict";
if (typeof(plupload) !== 'undefined') {
var uploader = new plupload.Uploader(ajax_vars.plupload);
uploader.init();
uploader.bind('FilesAdded', function (up, files) {
$.each(files, function (i, file) {
// console.log('append'+file.id );
$('#aaiu-upload-imagelist').append(
'<div id="' + file.id + '">' +
file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
'</div>');
});
up.refresh(); // Reposition Flash/Silverlight
uploader.start();
});
uploader.bind('UploadProgress', function (up, file) {
$('#' + file.id + " b").html(file.percent + "%");
});
// On erro occur
uploader.bind('Error', function (up, err) {
$('#aaiu-upload-imagelist').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('FileUploaded', function (up, file, response) {
var result = $.parseJSON(response.response);
// console.log(result);
$('#' + file.id).remove();
if (result.success) {
$('#profile-image').css('background-image','url("'+result.html+'")');
$('#profile-image').attr('data-profileurl',result.html);
$('#profile-image_id').val(result.attach);
var all_id=$('#attachid').val();
all_id=all_id+","+result.attach;
$('#attachid').val(all_id);
$('#imagelist').append('<div class="uploaded_images" data-
imageid="'+result.attach+'"><img src="'+result.html+'" alt="thumb" /><i class="fa
deleter fa-trash-o"></i> </div>');
delete_binder();
thumb_setter();
}
});
$('#aaiu-uploader').click(function (e) {
uploader.start();
e.preventDefault();
});
$('#aaiu-uploader2').click(function (e) {
uploader.start();
e.preventDefault();
});
}
});
© Stack Overflow or respective owner