2017-03-05 123 views
0

我需要一些上傳視頻文件到數據庫的幫助。PHP&上傳到數據庫

當我上傳我的腳本成功,但沒有發生在數據庫中,沒有文件。

<html> 
<head> 

<title> upload </title> 
<link rel='stylesheet' href='style.css' /> 
</head> 
<body> 


    <?php 
    include 'connect.php'; 

    ?> 

<div id='box'> 
    <form method='post' enctype='multipart/form-data'> 
    <?php 
    if (isset($_FILES['video'])) { 

    $name = $_FILES['video']['name']; 
    $type = explode('.', $name); 
    $type = end($type); 
    $size = $_FILES['video']['size']; 
    $random_name = rand(); 
    $tmp = $_FILES['video']['tmp_name']; 
    if ($type != 'MOV' && $type != 'mov' && $type != 'QucikTime-film'){ 
     $message = "Video Format Not Supported !"; 
    } else { 
     move_uploaded_file($tmp, 'videos/'.$random_name.'.'.$type); 

     { 

      mysqli_query($connect,"INSERT into videos VALUES (''. '$name', 'videos/$random_name.$type')"); 
       $message = "Successfully Uploaded ! "; 
       } 

       } 
       echo "$message <br/><br/>"; 
       } 

我在這裏做錯了什麼?

我connect.php應該是所有設置

define("DB_SERVER", "localhost:3306"); 
define("DB_USER", "root"); 
define("DB_PASSWORD", "root"); 
define("DB_DATABASE", "video_system"); 

$connect = mysqli_connect(DB_SERVER , DB_USER, DB_PASSWORD, DB_DATABASE); 
+0

你需要上傳文件或文件名嗎?因爲在當前版本的代碼中,您只需將文件名放在 –

+1

***中,需要將視頻文件上傳到數據庫中。***您無法上傳文件。只有路徑和名稱。 –

+0

謝謝。我只是添加了我的完整代碼。 – user3017725

回答