蔭嘗試使用PHP和MySQL插入文件夾中的圖像,但圖像不是在文件夾中的數據庫 存儲以及這是我的PHP代碼圖像不使用PHP和MYSQL
if(isset($name)) {
$pass = base64_encode($pass);
$cpass = base64_encode($cpass);
$image_name = $_FILES['image']['name'];
$image_temp = $_FILES['image']['tmp_name'];
$image_type = $_FILES['image']['type'];
if ($image_type == 'image/png' || $image_type == 'image/jpg' || $image_type == 'image/iso' || $image_type = 'image/gif') {
$upload = move_uploaded_file('uploads1/' . $_FILES['image']['name']);
if($upload) {
$reg_query = mysqli_query($conn, "INSERT INTO `quiz_register`(`name`, `email`, `mobile`, `password`, `cpassword`, `image`) VALUES ('$name','$mail','$cell','$pass','$cpass','$image_name')");
if ($reg_query) {
echo 'success';
} else {
echo 'fail';
}
}
}
}
這是我的HTML代碼
<form method="post" action="" enctype="multipart/form-data">
<input type="text" name="name" placeholder="name" class="form-control" id="name"> <br>
<input type="email" name="mail" placeholder="[email protected]" class="form-control" id="mail"> <br>
<input type="text" name="mobile" placeholder="Mobile" class="form-control" id="mobile"> <br>
<input type="password" name="password" placeholder="password" class="form-control" id="password"> <br>
<input type="password" name="cpassword" placeholder="confirm-password" class="form-control" id="cpassword"> <br>
<input type="file" name="image" id="file" class="form-control" required> <br>
</form>
此代碼對你有幫助 – 2017-04-01 06:38:18
我想你的代碼,但是當IAM插入,圖像列顯示quiz_register表空白,其餘的值將除了圖像 –
在其中輸入IMAGE_NAME您使用$ filepath1我是更新我的代碼 – 2017-04-01 06:59:50