輸入端 newadd.php
<form enctype="multipart/form-data" method="post" action="newadd_done.php" >
<type="file" name="photo">
<input type="sumbit" value="send" name="button">
接收端newadd_done.php
//圖片檔案上傳
if(isset($_FILES["photo"]["size"])){
$file = fopen($_FILES["photo']["tmp_name"],"rb");
$fileContents = fread($file,filesize($_FILES["photo"]["tmp_name]));
fclose($file);
$fileContents = base64_encode($fileContents);
$conn = mysql_mysqli_connect('localhost'.'root','password','db_name');
mysqli_set_charset($conn,"UTF8");
$sql = "INSERT INTO students (photo) VALUES ('$fileContents') WHERE id='$id'";
mysql_query($conn,$sql);
mysql_close($conn);
}