0
我想將圖像存儲到mysql數據庫中,但在ajax頁面$_FILE['textfield_Name']['temp_name']
不能識別它。幫我解決這個問題。
這是我的文件頁面代碼
<form class="form-horizontal signUPForm" method="post" action="most_wanted_ajax.php">
<label for="images">Upload Image</label>
<input type="file" name="images">
<br>
<button type="submit" id="add" value="Submit" >Add Most Wanted</button>
</form>
我jQuery代碼是:
$("#add").click(function (e){
$.post($(".signUPForm").attr("action"),$(".signUPForm").serializeArray(),function(res){
if(res!=null){
alert("mosted wanted added");
}
else
{
alert("Somthing is fishy");
}
});
});
這裏是我most_wanted_ajax.php代碼
<?php
if(getimagesize($_FILES['images']['tmp_name'])==FALSE)
{}
else
{
$image=addslashes($_FILES['images']['tmp_name']);
$image= file_get_contents($image);
$image= base64_encode($image);
$con=mysqli_connect("localhost","root","","ecopsweb");
$insertSQL="insert into most_wanted(images) values('".$image."')";
$rs= mysqli_query($con, $insertSQL);
$id= mysqli_insert_id($con);
header("location: missing_person_info.php");
}
?>
在most_wanted_ajax.php頁給出兩個錯誤
說明:未定義指數:在 Ç圖像:\瓦帕\ WWW \ eCopsWeb \ adminModule \ most_wanted_ajax.php上線3
警告:和getimagesize():文件名不能在 C是空的:\瓦帕\ WWW \ eCopsWeb \ adminModule \ most_wanted_ajax.php上線3
非常感謝,先生它的工作..... :) –
@RajeevSrivastava歡迎你。 – Saty
亞肯定先生..... :) –