开发者

php - upload file - filterting types to upload

<?php
if (($_FILES["fileToUpload"]["type"] == "image/gif")
  || ($_FILES["fileToUpload"]["type"] == "image/jpeg")
  || ($_FILES["fileToUpload"]["type"] == "image/png" )
  && ($_FILES["fileToUpload"]["size"] < 10000))
  {
  开发者_C百科move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
    "http://www.nhl-statistics.com/scripts/upload" . $_FILES["fileToUpload"]["name"]);
  }
else
  {
  echo "Files must be either JPEG, GIF, or PNG and less than 10,000 kb";
  }

no matter what i enter it seems to go to the else statement.


Have you looked at the content of $_FILES?

Use var_dump($_FILES); to see what values you get, that might help you pinpoint your issue.


The size is in bytes, not kilobits, you're only allowing files under the size of 78kb/10kB to be uploaded, but your echo says that files up to 10,000kb can be uploaded.

You might be uploading too large files.


Fix this:

move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "path/to/upload/folder" . $_FILES["fileToUpload"]["name"]);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜