//Add this product into database now
$sql = "INSERT INTO products
(product_name,price,details,category,
subcategory,date_added)
VALUES ('$product_name','$price','$details','$category',
'$subcategory',now())";
//now() will add todays date in database
if($result = mysqli_query($conn,$sql)){
$pid = mysqli_insert_id($conn);//Generated an auto-generated id
//Place image in the folder
$newname = "$pid.jpg";
move_uploaded_file($_FILES['fileField']['temp_name'],"../inventory_images/$newname");//$_FILES is a global variable.
header("location: inventory_list.php");//if you will not include this line then it will add the same product again if you refresh the page.
exit();
}
else{
echo"Data didn't inserted in the database";
}
コードを実行すると、データは正しく挿入されますが、アップロードした画像のディレクトリをチェックすると何もありませんフォルダ。できるだけ早く私を助けてください。PHPを使用してディレクトリに画像をアップロードしようとしています
エラー報告はオンになっていますか? – MonkeyZeus
ディレクトリが書き込み可能であることを確認してください。 Chmod – Akintunde007
正しいフォルダにアップロードしようとしていることを再度確認します。相対的なパス、特に '../'の場合は、常に神経質になります。p –