2014-10-22 52 views
0

這裏是我的代碼上傳視頻,但視頻既不去文件夾也不去數據庫。但在相同的視頻文件字段,如果你上傳的圖像或音頻,它的工作,我也設置upload_max_filesize在php.ini 500M。任何人都可以提前表示感謝。視頻不上傳到mysql數據庫。視頻圖像和音頻插入在相同的視頻文件字段

這是我用來上傳視頻的代碼。

<?php 
mysql_connect("localhost","root",""); 
mysql_select_db("test"); 

if(isset($_POST['submit'])) 
{  
     $id=$_POST['id']; 
     $video=$_FILES['vid']['name']; 
     $type=$_FILES['vid']['type']; 
     $size=$_FILES['vid']['size']; 
     $tempname=$_FILES['vid']['tmp_name']; 
     $dir="uploadvideo/".$video; 
     move_uploaded_file($tempname,"$dir"); 
$insert=mysql_query("insert into myblog(`video`) values ('$video')")or die(mysql_error()); 
     if($insert)  
     { 
      echo "<script>alert('Inserted Succesful')</script>"; 


    } 

} 
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<body> 

<form action="" method="post" enctype="multipart/form-data"> 

<label for="file" class="tbl">Filename:</label> 
<input type="file" name="vid" id="file"><br> 
<input type="submit" name="submit" value="Submit"> 
</form> 


</body> 
</html> 

回答

1

php.ini

查找:

post_max_size = 8M 

upload_max_filesize = 2M 

max_execution_time = 30 

max_input_time = 60 

memory_limit = 8M 

更改爲:

post_max_size = 750M 

upload_max_filesize = 750M 

max_execution_time = 5000 

max_input_time = 5000 

memory_limit = 1000M 
+0

謝謝@ Damon.s它只能增加的post_max_size。 – 2014-10-22 06:19:04

+0

你還不能上傳你的視頻? – talkhabi 2014-10-22 06:22:31

+0

是的,它現在可以上傳所有類型的視頻。 @ Damon.s – 2014-10-22 06:24:18

0
<?php 

$servername = "localhost"; 
$username = "root"; 
$password = ""; 
$dbname = "test"; 


$conn = new mysqli($servername, $username, $password, $dbname); 


if ($conn->connect_error) { 
    die("Database connection failed: " . $conn->connect_error); 
} 

if(isset($_POST['submit'])) 
{  
    $id=$_POST['id']; 
    $video=$_FILES['vid']['name']; 
    $type=$_FILES['vid']['type']; 
    $size=$_FILES['vid']['size']; 
    $tempname=$_FILES['vid']['tmp_name']; 
    $dir="uploadvideo/".$video; 
    move_uploaded_file($tempname,"$dir"); 
    $sql = "INSERT INTO myblog (`video`) VALUES ('".$video."')"; 
    $result = mysqli_query($conn, $sql); 

    if($result)  
    { 
     echo "<script>alert('Inserted Succesful')</script>"; 
    } 
}