-- โดยมีปัญหา คือ หลังจากที่อัพโหลดรูปภาพแล้ว ไฟล์ที่อัพโหลดยังค้างอยู่ในหน้าต่างอัพโหลด โดยจริงๆ แล้วเมือทำการอัพโหลดลงบอร์ดกระทู้เเล้วจะต้องไม่มีรูปภาพค้างอยู่ แต่นี้พอทดลองอัพไปแล้วก็ไฟล์รูปภาพก็ยังค้าง อยู่ที่เดิม
-- จึงอยากทราบว่าจะมีวิธีการแก้ไขอย่างไรอยาก วิธีการทำให้เมื่ออัพโหลดลงในบอร์ดกระทู้เเล้วไฟล์รูปภาพหายไปทุกครั่งจะต้องมีวิธีการอย่างไรบางครับ
**อันนี้เป็นโคดทีรี่สำหรับ อัพโหลดของผมครับ
โค้ด: เลือกทั้งหมด
jQuery(function ($) {
$("#uploader").plupload({
runtimes: 'html5',
url: './posting.php?mode=post&f=2',
max_file_size: '262144b',
unique_names: true,
rename: true,
filters: [{title: 'Images', extensions: 'gif,png,jpeg,jpg,tif,tiff,tga'}],
headers: {'X-PHPBB-USING-PLUPLOAD': '1', 'X-Requested-With': 'XMLHttpRequest'},
file_data_name: 'fileupload',
multipart_params: {'add_file': '\u0E2A\u0E48\u0E07\u0E44\u0E1F\u0E25\u0E4C\u0E17\u0E35\u0E48\u0E40\u0E25\u0E37\u0E2D\u0E01'},
form_hook: '#postform',
dragdrop: true,
views: {
list: true,
thumbs: true,
active: 'thumbs'
},
init: {
BeforeUpload: function (up, file) {
$('.file-list-container').removeClass('hidden');
up.settings.multipart_params = {
filename: file.name
};
},
FileUploaded: function (up, file, response) {
phpbb.plupload.insertRow(file);
$('.file-list-container').removeClass('hidden');
var json = {},
row = $('#file-list-container').find('#' + file.id),
error;
// Hide the progress indicator.
row.find('.file-progress').hide();
try {
json = JSON.parse(response.response);
} catch (e) {
error = 'Error parsing server response.';
}
file.attachment_data = json.data[0];
row.attr('data-attach-id', file.attachment_data.attach_id);
row.find('.file-inline-bbcode').show();
row.find('.file-status').addClass('file-uploaded');
var index = $('#file-list-container .attach-row').length - 1;
phpbb.plupload.update(json.data, 'addition', index, [json.download_url]);
},
UploadComplete: function (up, files) {
//console.log(phpbb.plupload.data);
console.log(up);
$.each($('#file-list-container').find('.attach-comment'), function (i) {
var index = i - 1;
if (index >= 0) {
var rname = up.files[index].attachment_data.real_filename;
//console.log(rname);
mattachInline(index, rname); //ส่งค่าไปฟังชั่น
console.log(index);
console.log(up.files[index]);
phpbb.plupload.data[index] = up.files[index].attachment_data;
phpbb.plupload.ids[index] = up.files[index].attachment_data.attach_id;
$.each($(this).find('input,textarea'), function () {
var name = $(this).prop('name');
$(this).prop('name', name.replace(/(\d)/, index));
document.getElementById('light').style.display = 'none';
document.getElementById('fade').style.display = 'none';
});
}
});
}
}
});
});
function mattachInline(index, filename)
{
insert_text('[attachment=' + index + ']' + filename + '[/attachment] \r\n');
document.forms[form_name].elements[text_name].focus();
}