我试图将图片上传到BLOB中的数据库中。每当我使用当前脚本时,它将文件路径放在BLOB而不是jpg文件中。我通过将blob更改为文本来测试它。
这是我每次尝试上传图片时的目的:
C:\ xamppv2 \ TMP \ php249C.tmp
我目前正在使用[' tmp_name']我认为这是导致此问题的原因。我想知道我要改变什么。
这是我的代码:
$tipe_file1 = $_FILES['image1']['tmp_name'];
$tipe_file2 = $_FILES['image2']['tmp_name'];
$tipe_file3 = $_FILES['image3']['tmp_name'];
$tipe_file4 = $_FILES['image4']['tmp_name'];
$prijs = $_POST['prijs'];
$naam = $_POST['fname'];
$beschrijving = $_POST['desc'];
$maat1 = $_POST['maat1'];
$maat2 = $_POST['maat2'];
$maat3 = $_POST['maat3'];
$maat4 = $_POST['maat4'];
$aMyUploads = array();
foreach ($_FILES as $aFile) {
if(0 === $aFile['error']){
$newLocation = ''.$aFile['tmp_name'];
if(0 === $aFile['error'] && (false !== move_uploaded_file($aFile['tmp_name'], $newLocation))){
$aMyUploads[] = $newLocation;
} else {
$aMyUploads[] = '';
}
}
}
$stmt = $conn->prepare("INSERT INTO `producten` (naam, beschrijving, prijs, maat1, maat2, maat3, maat4, image1, image2, image3, image4) VALUES
(:naam, :beschrijving, :prijs, :maat1, :maat2, :maat3, :maat4, :image1, :image2, :image3, :image4)");
$stmt->execute(array(":naam"=>$naam, ":beschrijving"=>$beschrijving, ":prijs"=>$prijs, ":maat1"=>$maat1, ":maat2"=>$maat2, ":maat3"=>$maat3, ":maat4"=>$maat4, ":image1"=>$aMyUploads[0], ":image2"=>$aMyUploads[1], ":image3"=>$aMyUploads[2], ":image4"=>$aMyUploads[3]));