尝试使用HTML表单上载MP4文件时未定义的索引

时间:2017-05-12 16:57:12

标签: php html forms

我尝试使用HTML表单使用PHP将视频上传到服务器。问题在于每次我尝试使用" note_video"上传.MP4文件。输入,.PHP文件提供

  

未定义的索引错误

包含我的所有变量。

以下表格:

         <form name="write_note" enctype="multipart/form-data" method="post" action="connect.php">

                <div class="group1">
                <table><tr>
                <td><div class="input-group input-group-lg title_little">
                    <span class="input-group-addon" id="sizing-addon1">Titulo: </span>
                    <input type="text" class="form-control" name= "news_name" placeholder="Titulo de noticia" aria-describedby="sizing-addon1">
                </div></td>
                <td><div class="dd_cat">
                      <select class="form-control" id="sel1" name = "category">
                        <option value="Rumor">Rumor</option>
                        <option value="Oficial">Oficial</option>                
                        <option value="Indie">Indie</option>
                      </select>
                    </div>
                </td>
                </tr>

                </table>
                <div class="form-group note_textarea">
                    <textarea class="form-control" name="news_desc" placeholder="descripcion" rows="1" id="comment"></textarea>
                </div>
                <div class="form-group note_textarea">
                    <textarea class="form-control" name="news_text" placeholder="contenido" rows="15" id="comment"></textarea>
                </div>
                    <div class="form-group">
                     <label for="exampleInputFile">Miniatura de Noticia</label>
                     <input type="file"  id="image" class="form-control" name="note_thumb" required>
                    <p class="help-block">Suba una foto preferiblemente cuadrada y no mas de 900KB.</p>
                    </div>
                    <div class="form-group">
                     <label for="exampleInputFile">Portada de Noticia</label>
                     <input type="file" id="image" class="form-control" name="note_pic" required>
                    <p class="help-block">Suba una foto preferiblemente cuadrada y no mas de 900KB.</p>
                    </div>
                    <div class="form-group">
                     <label for="exampleInputFile">Video de la noticia</label>
                     <input type="file" accept= "video" class="form-control" name="note_video" required>
                    <p class="help-block">Suba un video preferiblemente en .MP4</p>
                    </div>
                </div>
        <button type="submit" name = "submit" id="submit" class="btn btn-default" style="width:40%; margin-right: 30%; margin-left: 30%;">Ingresar Nota</button>
        </form>

这就是PHP:

<?php
$dbc = mysqli_connect('localhost','root', 'root', 'test_noticia');
if (!$dbc){
    die('Not connected: ' . mysql_error());
}
//echo 'connected';

$p_titulo= $_POST['news_name'];

$imgData =addslashes(file_get_contents($_FILES['note_thumb']['tmp_name']));
$imageProperties = getimageSize($_FILES['note_thumb']['tmp_name']);

$img2Data =addslashes(file_get_contents($_FILES['note_pic']['tmp_name']));
$image2Properties = getimageSize($_FILES['note_pic']['tmp_name']);

$sql = "INSERT INTO pics_and_video(image1Type ,image1Data, image2Type, image2Data, titulo)
VALUES('{$imageProperties['mime']}', '{$imgData}', '{$image2Properties['mime']}', '{$img2Data}', '{$p_titulo}')";
if(mysqli_query($dbc, $sql)){
    //echo '<script>alert("Image Inserted into Database")</script>'; 

    echo $name;
}else{echo '<script>alert("OH no")</script>';}
?>

如果我上传图片而不是视频,我就不会收到错误,但我确实需要上传视频文件hahaah。

0 个答案:

没有答案