โดยถ้าหากผู้ที่จะต้องการพัฒนา Extension สำหรับเว็บบอร์ด phpbb ที่จะใช้งานเกี่ยวกับการบันทึกไฟล์เพื่อที่จะนำไปใช้งานในกระบวนต่อไปนั้น โดยที่ไม่ต้องการจะอิงการทำงานการแนบไฟล์ของเดิมที่เว็บบอร์ด phpbb มีอยู๔่แล้วก็สามารถที่จะได้โดยไม่ลำบากมากนั้นก็จะมีวิธีการเขัยนโคดดังขั้นตอนต่อไปนี้
1.สร้างโคดที่เป็นส่วนการทำงานของหน้า html
โค้ด: เลือกทั้งหมด
<form id="" method="post" action="{T_ACTION}" enctype="multipart/form-data">
<h2>ตั้งค่าทั่วไป</h2>
<div class="panel">
<div class="inner">
<fieldset>
<dl>
<input type="hidden" name="next_id" value="{ID_NEW}">
<dt><label for="timezone">Picture</label></dt>
<dd>
<input type="file" name="image_pay"><br>
</dd>
</dl>
<dl>
<dt><label for="timezone">วิธีการชำระเงิน</label></dt>
<dd> <input type="submit" value="save" name="pay" class="button2">
<input type="submit" name="pay" value=" 2 " class="button1"></dd>
</dl>
</fieldset>
</div>
</div>
</form>
3.สร้างฐานข้อมูลสำหรับการเก็บข้อมูล
4.สร้างโคดที่เป็นส่วนการทำงานของหน้า php
โค้ด: เลือกทั้งหมด
$upload_file = $request->file('image_pay');
print_r($phpbb_root_path);
print_r($upload_file);
$tmp_file = $upload_file['tmp_name'];
preg_match('/(.*)\/(.*)/', $tmp_file, $output_array);
$tmp_file1 = str_replace($output_array['1'], 'images/id_no', $tmp_file);
move_uploaded_file($upload_file['tmp_name'], $tmp_file1);
$sql = "UPDATE `phpbb_m_package_register` SET reg_img_id_no = '" . $tmp_file1 . "' WHERE reg_id = " .
$pay_id_user;
$this->db->sql_query($sql);
ผลลัพธ์ที่ได้ถูกบันทึกลงในฐานข้อมูล
ผลลัพธ์ที่ได้ถูกบันทึกลงในโฟลเดอร์
บทความที่เกี่ยวข้อง
การสร้าง Extension ใน phpbb
การสร้าง controller สำหรับ phpbb
Event listenner - เขียน Extension บน phpBB 3.1