如何通过php代码上传.zip文件?
答案 0 :(得分:2)
此代码适合我!
<?php
if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "application/zip") && ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "<img src=\"images/logo-top.jpg\"/>";
echo "Thank you<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
}
}
}
else
{
echo "<img src=\"images/logo-top.jpg\"/><br />";
echo "Invalid file";
}
?>
答案 1 :(得分:1)
Check out the upload file tutorial
确保为:
指定正确的设置请参阅: