I have a php script. The script can't upload a video.
When I submit the form, I get the error: Warning: getimagesize(): Filename cannot be empty. I have search on the internet, I change getimagesize in file() and $_FILES["uploaded_file"]["type"]; But this doesn't work.
Can someone help me? How can I upload a video to the upload_video folder? The insert into in de database is working.
my script is:
include 'connect.php';
$target_dir = "upload_video/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
var_dump($imageFileType);
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);//this is wrong
}
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
if($imageFileType != "mp4" )
{
echo "only mp4 extensions";
$uploadOk = 0;
}
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "the video ". basename( $_FILES["fileToUpload"]["name"]). " is upload.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
$sql = "INSERT INTO upload_video (file, description)VALUES (?, ?)";
$stmt = $link->prepare($sql);
$stmt->bind_param("ss", $target_file, $description );
$beschrijving = $_POST['beschrijving'];
$stmt->execute();
if ($sql) {
} else{
echo "Data not add";
}
$stmt->close();
mysqli_close($link);