douwen5546 2012-03-21 17:16
浏览 133

PHP上传视频

I have been trying to upload an image and video and update data at the same time, I can upload the image, but it wont upload when I am also uploading a video and the data gets updated but my video will not upload. I've been trying to get the video to upload for weeks with no success... This is what I've tried:

I've tried adding MIME Types to my .htaccess file

AddType video/avi .avi
AddType video/quicktime .mov
AddType video/mpeg .mpeg .mpg
AddType video/mp4 .mp4

and I've tried changing my phpinfo settings in my php5.ini file

max_execution_time = 3000
upload_max_filesize = 50MB

Here is the PHP upload code

if (($_FILES["image"]["type"] == "image/jpeg") || ($_FILES["image"]["type"] == "image/pjpeg")){
            if ($_FILES["image"]["error"] > 0){
                echo $_FILES["image"]["error"];
            }else{
                move_uploaded_file($_FILES["image"]["tmp_name"],
                "../upload/video_1_" . date("Ymd") . $_FILES["image"]["name"]);
                move_uploaded_file($_FILES["video"]["tmp_name"],
                "../upload/video_2_" . date("Ymd") . $_FILES["video"]["name"]);     
                $class->update($id, $title, $description, $image, $video);
                echo "<div style='padding-left:50px'><strong>Updated!</strong></div>";
            }
        }else{
            echo "<div style='padding-left:50px'><strong>Invalid Image!</strong></div>";
        }

I ran a print_r on $_FILES and it returned an empty array

My Video size is 40.9MB

Any help or a point in the right direction would be appreciated, Thanks in advanced, J

This is my form

<form action="Videos.php?action=updatesubmit" method="post" enctype="multipart/form-data">
<input type="hidden" value="<?php echo $array['id']; ?>" name="id" />
<p>
<label for="name" style="vertical-align:top;">Title</label>
<input type="text" name="title" id="title" value="<?php echo $array['title']; ?>" />
</p>
<p>
<label for="description" style="vertical-align:top;">Description</label>
<textarea name="description" id="description" cols="70" rows="20"><?php echo $array['description']; ?></textarea>
</p>
<p>
<label for="image">Image</label>
<input type="file" name="image" id="image" value="<?php echo $array['image']; ?>" />
</p>
<p>
<label for="video">Video</label>
<input type="file" name="video" id="video" value="<?php echo $array['video']; ?>" />
</p>

<p>
<input type="submit" name="submit" id="submit" value="Update" />
</p>

</form>
  • 写回答

3条回答 默认 最新

  • dongruyan4948 2012-03-21 17:19
    关注

    If $_FILES is empty and you're not getting an error message when you upload, chances are you forgot to set enctype="multipart/form-data" in the <form> tag.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)