Php Video Upload Script

前端 未结 2 826
傲寒
傲寒 2021-01-03 16:22

I am trying to allow users to upload videos via this form

       
相关标签:
2条回答
  • 2021-01-03 17:03

    Try the below PHP code in this code you can have some Restrictions on Upload you can set the Exts that you need to allow in upload..

    HTML FORM CODE

    <html>
    <body>
    <form action="upload_file.php" method="post"   enctype="multipart/form-data">
      <label for="file">Filename:</label>
         <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>
    </body>
    </html> 
    

    PHP CODE BELOW

    <?php
    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/pjpeg"))
    && ($_FILES["file"]["size"] < 20000)
    && in_array($extension, $allowedExts))
      {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo "Upload: " . $_FILES["file"]["name"] . "<br />";
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<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"]);
          echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
          }
        }
      }
    else
      {
      echo "Invalid file";
      }
    ?> 
    

    For Any Other Reference kindly Check Here http://w3schools.com/php/php_file_upload.asp Or Post A Comment

    0 讨论(0)
  • 2021-01-03 17:10

    In php.ini Find and update as following:

    post_max_size = 8M
    
    upload_max_filesize = 2M
    
    max_execution_time = 30
    
    max_input_time = 60
    
    memory_limit = 8M
    
    Change to:
    
    post_max_size = 750M
    
    upload_max_filesize = 750M
    
    max_execution_time = 5000
    
    max_input_time = 5000
    
    memory_limit = 1000M
    
    0 讨论(0)
提交回复
热议问题