我正在開發一個小型的用戶維護的在線商店,並試圖讓我的最終用戶(商店管理員)能夠上傳產品圖形。但是,當我運行此腳本時,它實際上並不存儲圖像。我從這裏的各種技巧和教程構建了這個腳本,並且除了圖像上傳部分以外都得到了一切。PHP腳本沒有正確上傳圖片
// Set the image target directory here
$target = "itemImages/";
$target = $target . basename($_FILES["image"]["name"]);
// Variables get POSTed here - just tack new ones on at the end.
// Various POSTs omitted for brevity
$pic=($_FILES["image"]["name"]);
// Places the picture in the folder
if(move_uploaded_file($_FILES["image"]['tmp_name'], "itemImages/"))
{
echo "The file " . basename($_FILES['uploadedfile']["name"]) . " has been uploaded.<br />";
}else {
echo "There was an issue adding this item. Please try again.<br />";
}
// Writes variables to the database
mysql_query("INSERT INTO tbl_item (itemNAME,itemDESC,itemCOST,itemHCOL,itemHSIZ,itemIMG)
VALUES ('$itemName','$itemDesc','$itemCost','$hasColor','$hasSize','$pic')");
mysql_close($con);
?>
任何幫助,提示,建議,洞察力等將非常感激。
是mysql更新和成功消息還行嗎? – 2012-08-10 14:35:26
你的'form'標籤上是否有正確的'enctype'? – Cfreak 2012-08-10 14:35:53
你能告訴我們