开发者

How can I tweak this so it will accept .flv files?

开发者 https://www.devze.com 2023-02-20 16:56 出处:网络
I want to tweak this so it can handle .flv files, can anyone please help me? <?php if ((($_FILES[\"file\"][\"type\"] == \"image/gif\")

I want to tweak this so it can handle .flv files, can anyone please help me?

    <?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
  {
 开发者_C百科 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";
  }
?>

Also, is there anything I need to change anywhere else on my server so that I can handle .flv files?

Thanks in advance.


Instead of video/flv, I had to do this for my site:

|| ($_FILES["file"]["type"] == "video/x-flv")

And then you probably want to make sure this is in your Apache config file:

AddType video/x-flv .flv
AddType application/x-shockwave-flash .swf

Obviously those lines will be different if you are using IIS or something similar, but you get the idea.


Add another OR condition in first IF... || ($_FILES["file"]["type"] == "video/flv")


These are all the suppored web video formats that can be embed into webpage :

if ((
 ($_FILES["file"]["type"] == "video/x-flv")
|| ($_FILES["file"]["type"] == "video/mp4")
|| ($_FILES["file"]["type"] == "video/mpeg")
|| ($_FILES["file"]["type"] == "video/ogg")
|| ($_FILES["file"]["type"] == "video/quicktime")
|| ($_FILES["file"]["type"] == "video/webm")
|| ($_FILES["file"]["type"] == "video/x-ms-wmv")
)
0

精彩评论

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