0
我試圖將圖像上傳到我的服務器,現在的代碼是非常簡單的,但它從來沒有通過的,如果測試,它總是直接轉到else語句,有執行的代碼,即;無效文件。如果下面的表單代碼...圖片上傳未上傳
<form action="take.php" method="get" onsubmit='return chequer()' enctype="multipart/form-data">
<input type="file" name="image1"/>
</form>
而且PHP腳本上傳的圖片是低於,這當然是在take.php文件:
if ($_GET["image"] == Null)
{
$sql = "INSERT INTO postable (description, dated, posterid, country, state, city, area)
VALUES
('$_GET[Desc]',NOW(),'$row[0]','$_GET[Country]','$_GET[State]','$_GET[City]','$_GET[area]')";
}
else {
$sql = "INSERT INTO postable (description, dated, image, posterid, country, state, city, area)
VALUES
('$_GET[Desc]',NOW(),'$_GET[image]','$row[0]','$_GET[Country]','$_GET[State]','$_GET[City]','$_GET[area]')";
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["image1"]["name"]));
if ((($_FILES["image1"]["type"] == "image/gif")
|| ($_FILES["image1"]["type"] == "image/jpeg")
|| ($_FILES["image1"]["type"] == "image/pjpeg"))
&& ($_FILES["image1"]["size"] < 65536)
&& in_array($extension, $allowedExts))
{
if ($_FILES["image1"]["error"] > 0)
{
echo "Return Code: " . $_FILES["image1"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["image1"]["name"] . "<br />";
echo "Type: " . $_FILES["image1"]["type"] . "<br />";
echo "Size: " . ($_FILES["image1"]["size"]/1024) . " Kb<br />";
echo "Temp file: " . $_FILES["image1"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["image1"]["name"]))
{
echo $_FILES["image1"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["image1"]["tmp_name"],
"upload/" . $_FILES["image1"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["image1"]["name"];
}
}
}
else
{
echo "Invalid file";
}
任何幫助會非常多讚賞。
在此先感謝...
什麼是錯誤?或者你希望我們閱讀代碼並找出答案?檢查錯誤日誌! – 2012-08-16 10:55:13
它不給我一個錯誤,它的作用是,如果測試失敗,直接進入else語句,並執行echo語句有...該代碼是不是在任何情況下複雜...... – Michael 2012-08-16 12:42:01
你改成' POST就像@Anup Singh說的那樣? – 2012-08-16 12:43:13