<div id="filediv"> <input name="file[]" type="file" id="file"/> </div> <br/> <input type="button" id="add_more" class="upload" value="Add More Files"/>
var abc = 0; //Declaring and defining global increement variable var counter = 0; var wrapper = $(".input_fields_wrap"); $(document).ready(function() { $('#add_more').click(function() { counter = counter+1; if(counter<=9){ $(this).before($("<div/>", {id: 'filediv'}).fadeIn('slow').append( $("<input/>", {name: 'file[]', type: 'file', id: 'file'}), $("<br/><br/>") )); }else{ alert("รูปเกิน 10 รูป"); e.preventDefault(); } }); //following function will executes on change event of file input to select different file $('body').on('change', '#file', function(){ if (this.files && this.files[0]) { abc += 1; //increementing global variable by 1 var z = abc - 1; var x = $(this).parent().find('#previewimg' + z).remove(); $(this).before("<div id='abcd"+ abc +"' class='abcd'><img id='previewimg" + abc + "' src=''/></div>"); var reader = new FileReader(); reader.onload = imageIsLoaded; reader.readAsDataURL(this.files[0]); $(this).hide(); $("#abcd"+ abc).append($("<img/>", {id: 'img', src: 'x.png', alt: 'delete'}).click(function() { $(this).parent().parent().remove(); })); } }); //To preview image function imageIsLoaded(e) { $('#previewimg' + abc).attr('src', e.target.result); }; $('#upload').click(function(e) { var name = $(":file").val(); if (!name) { alert("First Image Must Be Selected"); e.preventDefault(); } }); });
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง