duan20145 2015-02-08 18:35
浏览 86
已采纳

使用PHP错误上传mp4文件

I'm trying to upload an mp4 file, although it won't go through. I can upload any image type so long as I put the format in, but any video format what so ever doesn't work. Mp4, mov, etc. This is the code I'm using to upload mp4

<?php

    session_start();

if(!isset($_SESSION["user"]) or !is_array($_SESSION["user"]) or empty($_SESSION["user"])) {
      // redirect to login page
}



$target_dir = ('../MEDIA/films/');
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image


// Check if file already exists

// Check file size

// Allow certain file formats
if($imageFileType != "MP4" ) {
    echo "Sorry, only MP4, MOV, M4V, MKV & AVI files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
    echo header('Location: main.php');
    } else {
    echo header('Location: main.php');
    }
}
?>

And my form code is:

<div class="container auth">
    <div id="big-form" class="well auth-box">
    <form class="form-horizontal"  action="video-upload.php" method="post" enctype="multipart/form-data">
        <fieldset>

          <!-- Form Name -->
          <legend>Uploading as <?= $_SESSION["user"]["firstname"] ?></legend>

          <!-- Textarea -->
               <div class="form-group">
            <div class="">              
    <input type="file" name="fileToUpload" id="fileToUpload">
            </div>
          </div>
<div class="form-group">
  <div class="col-md-8">
    <button id="updateprofile" value="Upload Video" name="updateprofile" class="btn btn-success">Submit</button>
  </div>
</div>
        </fieldset>
      </form>
    </div>
    <div class="clearfix"></div>
  </div>
</html>

</div>
  • 写回答

1条回答 默认 最新

  • doulaobi7988 2015-02-08 18:43
    关注

    Maybe your video files are just too large. Check upload_max_filesize and post_max_size in you php.ini, if possible.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码