我在如何替换我的文件夹和数据库上的图像时遇到了困难。我对如何编码一无所知。有人可以帮助我吗?
我的代码是这样的。
if ((($_FILES["prodImage"]["type"] == "image/gif")
|| ($_FILES["prodImage"]["type"] == "image/jpeg")
|| ($_FILES["prodImage"]["type"] == "image/pjpeg")
|| ($_FILES["prodImage"]["type"] == "image/jpg")
|| ($_FILES["prodImage"]["type"] =="image/png"))
&& ($_FILES["prodImage"]["size"] < 2000000))
{
if (file_exists("product_images/" . $_FILES["prodImage"]["name"]))
{
?>
<script language="javascript">
alert("<?php echo $_FILES["prodImage"]["name"] . " already exists. ";?>");
window.history.back();
</script>
<?php
}
else
{
move_uploaded_file($_FILES["prodImage"]["tmp_name"],
"product_images/" .$_FILES["prodImage"]["name"]);
$im = $_FILES["prodImage"]["name"];
$qry = "INSERT INTO products(productID, productName, productDesc, price, image, product_status, product_type) VALUES(null,'$prodName','$prodDesc','$price','$im','$category', '$prodtype')";
$result = @mysql_query($qry);
//Check whether the query was successful or not
}
}