-2

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); 
wesley3
  • 11
  • 1
  • 2
    in video upload why you use [**`getimagesize`**](http://php.net/manual/en/function.getimagesize.php) ?? This use to ***determine the size of any given image file*** – Abdulla Nilam Jan 25 '16 at 19:18
  • What on Earth are you even trying to do with `getimagesize()`? Not only does it not apply to non-image files, it also needs to reference a file *on the file system*, and above all you're not even using the result of that operation for anything. – David Jan 25 '16 at 19:22

1 Answers1

0

The getimagesize() used to determine the size of any given image file and return the dimensions along with the file type.

No use for getimagesize() here. Clear it out from the code. It may works.

Anas
  • 971
  • 13
  • 28