将.mp4和.ogg视频文件上传到服务器PHP

时间:2012-02-24 12:54:00

标签: php

我正在尝试将.mp4和.ogg视频文件上传到服务器。我使用WAMP作为本地服务器来测试它。我有一个表单,但是当我在填写文件字段后提交它时,服务器就像“等待本地主机”然后不上传它。这是我的代码

HTML

<form enctype="multipart/form-data" action="addvideo.php" method="post">
<table width="418">
  <tr>
    <td width="173">&nbsp;</td>
    <td width="233">&nbsp;</td>
  </tr>
  <tr>
    <td>Upload video image</td>
    <td><label for="img"></label>
    <input type="file" name="img" id="img" /></td>
  </tr>
  <tr>
    <td>Upload video</td>
    <td><label for="video"></label>
    <input type="file" name="video" id="video" />
    <input type="hidden" name="MAX_FILE_SIZE" value="20000000" />
    </td>
  </tr>
  <tr>
    <td valign="top">Description</td>
    <td><label for="description"></label>
    <textarea name="description" id="description" cols="30" rows="5"></textarea></td>
  </tr>
  <tr>
    <td>Category</td>
    <td>
    <?php
    $sql=mysql_query("SELECT * FROM image_categ");
    ?>
    <label for="category"></label>
    <select name="category" id="category">
    <?php
    while($cat_rows=mysql_fetch_assoc($sql)){
    ?>
      <option value="<?php echo $cat_rows['id'];?>"><?php echo $cat_rows['categ_name'];?></option>
    <?php
    }
    ?>
    </select>

    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" id="submit" value="Submit" /></td>
  </tr>
</table>
</form>

PHP:

if(isset($_POST['submit'])){

    $vid_img=$_FILES['img']['name'];
    $video=$_FILES['video']['name'];
    echo $video;
    $description=$_POST['description'];
    $categ=$_POST['category'];

    $sql=mysql_query("INSERT INTO videos(categ_id,video_name,video_image,description)VALUES('$categ','$video','$vid_img','$description')");
    $target1="../images/gallery images/";
    $target2="../videos/";
    $target1=$target1.basename($_FILES['img']['name']);
    $target2=$target2.basename($_FILES['video']['name']);
    if(move_uploaded_file($_FILES['img']['tmp_name'],$target1)&&move_uploaded_file($_FILES['video']['tmp_name'],$target2)){
        header("Location:dashboard.php?msg2=Video added");
    }else{
        header("Location:dashboard.php?msg=Sorry, try again.");
    }
}

我在php.ini文件中有什么要改变的吗?我将很感激帮助

0 个答案:

没有答案