视频上传问题php mySQL

时间:2019-02-14 12:05:12

标签: php mysql file video upload

使用php,mySQL和HTML / CSS创建视频上传器时遇到了困难。我对php和mySQL还是很陌生,但是我对两者有基本的了解。我按照教程进行了修改。但是,当我尝试上传视频文件时,它会返回;

  

警告:move_uploaded_file(uploads / testVideo.mov):无法打开流:在/Applications/XAMPP/xamppfiles/htdocs/VarcFiles/upload.php的第24行,权限被拒绝

     

警告:move_uploaded_file():无法在第24行的/Applications/XAMPP/xamppfiles/htdocs/VarcFiles/upload.php中将“ / Applications / XAMPP / xamppfiles / temp / phpwWU1M4”移动到“ uploads / testVideo.mov”

这些警告下方将是视频,该视频无法播放。

存储视频的数据库表video仍在工作。

注意:包括“ config.php”;已经使用变量$ link连接数据库。

<?php

include "config.php";

extract($_POST);

$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);

if(isset($_POST['upd'])){
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

// Allow certain file formats
if($imageFileType != "mp4" && $imageFileType != "mpeg-4" && $imageFileType != "mov"
&& $imageFileType != "avi" && $imageFileType != "wmv" && $imageFileType != "mpeg-ps" 
&& $imageFileType != "flv" && $imageFileType != "3gpp" && $imageFileType != "webm") {
echo "Desculpa, só aceitamos MOV, MPEG-4, MP4, AVI, WMV, MPEG-PS, FLV, 3GPP, & WebM";
}
else{
$video_path=$_FILES['fileToUpload']['name'];

mysqli_query($link, "INSERT INTO video(video_name) VALUES('$video_path')");

move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$target_file);

echo "Carregado ";
}

}
//display all uploaded video
if('disp'){
$query=mysqli_query($link, "SELECT * FROM video");

while($all_video=mysqli_fetch_array($query))
{
?>

 <video width="300" height="200" controls>
 <source src="uploads/<?php echo $all_video['video_name']; ?>" type="video/mp4">
</video> 

<?php } } ?>

接下来是HTML文件,

<form action="upload.php" method="post" enctype="multipart/form-data">
    Selecione um vídeo para enviar:
    <input type="file" name="fileToUpload"/>
    <input type="submit" value="Carregar um vídeo" name="upd"/><br>
    <input type="submit" value="Exibir vídeo" name="disp"/>
</form>

我正在关注的教程在这里, https://www.phptpoint.com/upload-video-in-php/

0 个答案:

没有答案