我有一个在本地安装(PHP4/MySQL)中设计的应用程序,它运行良好。自从我将它移到实时安装(PHP5/MySQL)以来,我除了问题什么都没有!我修复了所有全局变量问题(让我学习 PDO,所以这不是一件坏事!)没有打开全局变量,所以我唯一的问题是文件上传。我尝试了 $_file 的 isset 测试,看起来变量从未设置过?有任何想法吗?
这是表单数据:
<form enctype="multipart/form-data" method="post" action="script_add_product.php" >
<input class="cp_forms_upload" type="file" name="full_image" />
<input class="cp_formsButton" type="submit" name="submit_button" value="Add Product" /></form>
这是PHP:
$full_image_url = $_FILES["full_image"]["name"];
if ((($_FILES["full_image"]["type"] == "image/gif")
|| ($_FILES["full_image"]["type"] == "image/jpeg")
|| ($_FILES["full_image"]["type"] == "image/pjpeg")
|| ($_FILES["full_image"]["type"] == "image/png"))
&& ($_FILES["full_image"]["size"] < 400000))
{
if ($_FILES["full_image"]["error"] > 0)
{
echo "Return Code: " . $_FILES["full_image"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["full_image"]["name"] . "<br />";
echo "Type: " . $_FILES["full_image"]["type"] . "<br />";
echo "Size: " . ($_FILES["full_image"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["full_image"]["tmp_name"] . "<br />";
if (file_exists("../Uploads/" . $_FILES["full_image"]["name"]))
{
echo $_FILES["full_image"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["full_image"]["tmp_name"],
"../Uploads/" . $_FILES["full_image"]["name"]);
echo "Stored in: " . "../Uploads/" . $_FILES["full_image"]["name"];
echo "<br /><br /><br />" . $full_image_url;
}
}
}
else
{
echo "Invalid file";
}
谢谢各位:)