dongzecai0684 2013-10-29 03:01
浏览 56
已采纳

视频上传器不适用于使用php的mp4

I have an uploader that works great with images but not so great with videos. I need it for videos. Ive already increased the file size in php.ini Anyone spot an error here? I just need it for mp4 videos.

The uploader responds with invalid file. Im uploading mp4 videos.

The code is really basic but im still missing something.

offline, im using xampp and online im using godaddy as my host.

PHP code:

$allowedExts = array("jpg", "jpeg", "gif", "png", "mp3", "mp4", "wma");
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);

if ((($_FILES["file"]["type"] == "video/mp4")
|| ($_FILES["file"]["type"] == "audio/mp3")
|| ($_FILES["file"]["type"] == "audio/wma")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg"))

&& ($_FILES["file"]["size"] < 20000000000000)
&& 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";
  }
?>

HTML:

<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> 
  • 写回答

3条回答 默认 最新

  • douyuanliao8815 2013-10-30 23:26
    关注

    Okay guys, thanks for the help. I figured it out. After hours....and hours........AND HOURS googling, making changes, and figuritivly beating my head against the wall, I have found that godaddy only allows a maximum of 128mb to be uploaded client-side. Not to be confused with the maximum file size a godaddy user can upload to their hosting account which is much, much larger.

    If anyone else has this issue with video uploads, there is a video converter that will DRASTICALLY reduce the amount of space a video takes up. It says it was made for people who use lightworks editor but Ive used it a bunch already with several videos. Too a 570mb video down to 90mb and a 5.1gb video down to 200mb.

    http://eyeframeconverter.wordpress.com/

    I also did the following steps

    1) drag a video into the eye-fram program

    2) hit the convert button on bottom

    3) make sure the settings are the following after hitting convert

    -Editting -->> LW FREE Mpeg2 I-Frame HD - Proxy Quarter Size

    -Delivery -->> H264 MP4 Profile High

    I really really hope this helps someone. Its frustrating when you cant pinpoint an answer with google and you have to call tech support.

    ------EDIT------

    The following link backs up the GoDaddy restriction if you go to the section under how to change your limit size, it tells you there is a maximum that you can set it to. Chances are, if this changes, the link will be updates.

    http://support.godaddy.com/help/article/1475/what-is-the-php-upload-limit-on-linux-hosting-accounts

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏