954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php form upload video files not working

I wish to limit uploading to the video files swf pps bmp pps png gif mpg mp3 and wav - i'm sure I have the file / type incorrect. can someone please give logical solution...

here's my code:

<?php
if ((($_FILES["file"]["type"] == "video/swf")
|| ($_FILES["file"]["type"] == "video/pps")
|| ($_FILES["file"]["type"] == "video/bmp")
|| ($_FILES["file"]["type"] == "video/pps")
|| ($_FILES["file"]["type"] == "video/png")
|| ($_FILES["file"]["type"] == "video/gif")
|| ($_FILES["file"]["type"] == "video/mp3")
|| ($_FILES["file"]["type"] == "video/wav"))
&& ($_FILES["file"]["size"] < 200000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "";
    echo "Type: " . $_FILES["file"]["type"] . "";
    echo "Size: " . ($_FILES["file"]["size"] / 200000) . " Kb";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "";

    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 "Thank you for your" . "upload/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>
fudgealtoid
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
 
I wish to limit uploading to the video files swf pps bmp pps png gif mpg mp3 and wav>


Not all of those are video files.(Or rather; the extensions of known video formats.)
Only SWF and MPG would qualify. Unless you also count animated images, in which case PNG and GIF would count as well.

But yea, you have the mime types wrong.
You can look up the proper mime types at w3schools.com .

Atli
Posting Pro
540 posts since May 2007
Reputation Points: 93
Solved Threads: 70
 

Maybe the trouble in php.ini maxfileupload.

crohole
Light Poster
34 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: