mindphp เขียน:ฟอร์มสำหรับ อัพโหลดไฟล์ ต้องมีกระทู้เพิ่มเติมโค้ด: เลือกทั้งหมด
enctype="multipart/form-data"
viewtopic.php?f=6&t=3281
ทำความเข้าใจ เรื่อง Input object แต่ละประเภท
viewtopic.php?f=72&t=11770
โค้ด: เลือกทั้งหมด
enctype="multipart/form-data"
โค้ด: เลือกทั้งหมด
<div class="col-sm-10">
<input type="file" name="upload_file" enctype="multipart/form-data" ><br/>
</div>
โค้ด: เลือกทั้งหมด
$file = $_POST['upload_file'];
// ตั้งค่าโฟลเดอร์ที่จะเก็บไฟล์ที่อัพโหลดเข้าไป
$uploaddir = './images/';
$uploadfile = $uploaddir . basename($file);
if (move_uploaded_file($_FILES['upload_file']['tmp_name'], $uploadfile))
{
require_once 'connect.php';
$sql = "INSERT INTO $table_con (name, use_date, ip)"
. "VALUES ('$name','$date','$ip')";
mysqli_query($con, $sql) or die('Save Error');
$last_id = mysqli_insert_id($con);
}
โค้ด: เลือกทั้งหมด
if (move_uploaded_file($_FILES['upload_file']['tmp_name'], $uploadfile))