gpt4 book ai didi

php - 文件上传适用于 PHP4 但不适用于 PHP5

转载 作者:行者123 更新时间:2023-11-30 23:50:54 29 4
gpt4 key购买 nike

我有一个在本地安装 (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";
}

谢谢大家:)

最佳答案

如果 file_uploads 设置为 On,请检查您的 php.ini

; Whether to allow HTTP file uploads.
; http://ph .net/file-uplollow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On

关于php - 文件上传适用于 PHP4 但不适用于 PHP5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11704165/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com