开发者

upload zip file

开发者 https://www.devze.com 2023-02-02 10:19 出处:网络
how to uplo开发者_如何学Cad a .zip file through php code? This code works for me! <?php if (($_FILES[\"file\"][\"type\"] == \"image/gif\") || ($_FILES[\"file\"][\"type\"] == \"application/zip\")

how to uplo开发者_如何学Cad a .zip file through php code?


This code works for me!

<?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";
    }

?>


Check out the upload file tutorial

Make sure to specify proper settings for:

  • file_uploads
  • upload_max_filesize
  • memory_limit
  • max_execution_time
  • post_max_size

See:

  • How to optimize your PHP installation to handle large file uploads
0

精彩评论

暂无评论...
验证码 换一张
取 消