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"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 200000) . " 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 "Thank you for your" . "upload/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

Recommended Answers

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 …

Jump to Post

All 2 Replies

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.

Maybe the trouble in php.ini maxfileupload.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.