อยากทราบวิธีการล้างค่าหลังทำการอัพโหลดเสร็จ ใน phpbb

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
Ittichai_chupol
PHP VIP Members
PHP VIP Members
โพสต์: 5410
ลงทะเบียนเมื่อ: 19/09/2018 10:33 am

อยากทราบวิธีการล้างค่าหลังทำการอัพโหลดเสร็จ ใน phpbb

โพสต์ที่ยังไม่ได้อ่าน โดย Ittichai_chupol »

-- ผมได้พัฒนา Extension ทีี่่ใช้สำหรับที่ใช้สำหรับ อัพโหลดรูปภาพ
-- โดยมีปัญหา คือ หลังจากที่อัพโหลดรูปภาพแล้ว ไฟล์ที่อัพโหลดยังค้างอยู่ในหน้าต่างอัพโหลด โดยจริงๆ แล้วเมือทำการอัพโหลดลงบอร์ดกระทู้เเล้วจะต้องไม่มีรูปภาพค้างอยู่ แต่นี้พอทดลองอัพไปแล้วก็ไฟล์รูปภาพก็ยังค้าง อยู่ที่เดิม
-- จึงอยากทราบว่าจะมีวิธีการแก้ไขอย่างไรอยาก วิธีการทำให้เมื่ออัพโหลดลงในบอร์ดกระทู้เเล้วไฟล์รูปภาพหายไปทุกครั่งจะต้องมีวิธีการอย่างไรบางครับ


**อันนี้เป็นโคดทีรี่สำหรับ อัพโหลดของผมครับ

โค้ด: เลือกทั้งหมด


   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();
    }



ขอให้วันนี้เป็นวันที่ดี
ภาพประจำตัวสมาชิก
Ittichai_chupol
PHP VIP Members
PHP VIP Members
โพสต์: 5410
ลงทะเบียนเมื่อ: 19/09/2018 10:33 am

Re: อยากทราบวิธีการล้างค่าหลังทำการอัพโหลดเสร็จ ใน phpbb

โพสต์ที่ยังไม่ได้อ่าน โดย Ittichai_chupol »

ตัวอย่างโคด

โค้ด: เลือกทั้งหมด


   insert_text('[attachment=' + index + ']' + filename + '[/attachment] \r\n');
        document.forms[form_name].elements[text_name].focus();
        $('#uploader').remove(); //ล้างค่าหลัง upload
        $('.muploader').append('<div id="uploader"></div>');
         pinit();


ขอให้วันนี้เป็นวันที่ดี
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 114