Bonjour, j'essaie d'uploader des videos dans ma bdd mais je n'y parviens pas
Voici mon code :
Code PHP:
session_start();
if(isset($_SESSION['Id'])){
if( !empty($_POST['product_name']) ){
if(!empty($_FILES)){
$file_name = $_FILES['upload_video']['name'];
$file_type = $_FILES['upload_video']['type'];
$file_tmp_name = $_FILES['upload_video']['tmp_name'];
$file_extension = strrchr($file_name, ".");
$file_destination = '../video/'.$file_name;
$valid_extensions = array( '.AVI', '.avi', '.MOV', '.mov', '.MPG', '.mpg', '.MP3', '.mp3', '.MP4', '.mp4' );
if( in_array( $file_extension, $valid_extensions )){
if(move_uploaded_file( $file_tmp_name, $file_destination )){
$create_product = $database->prepare( "INSERT INTO create_product(IdUser, productName, videos)
VALUES(?, ?, ?)" );
$create_product->execute(array( $_SESSION['Id'], $_POST['product_name'], $file_destination ));
echo "video has been uploaded";
}else{
echo "video hasnt been uploaded";
}
}else{
echo "valid extensions '.AVI', '.avi', '.MOV', '.mov', '.MPG', '.mpg', '.MP3', '.mp3', '.MP4', '.mp4' ";
}
echo 'Nom : '.$file_name;
echo 'Extension : '.$file_extension;
var_dump($_FILES);
}
}else{
echo "empty product name";
}
}else{
echo "id doesnt exist";
}
Voici mes erreurs :
video hasnt been uploaded
Nom : video_2.mp4
Extension : .mp4
array (size=1)
'upload_video' =>
array (size=5)
'name' => string 'video_2.mp4' (length=11)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 1
'size' => int 0
Dans ma bdd j'ai mit le champs video en longblob et les videos que je tente d'uploader ne font qu'entre 2Mo et 7Mo
-----