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条)

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致