i´d like to save videos on my server via php script. i pass a filename and insert it to my $file variable which is the actual file path to save. echo is correct (Videos/2.mp4), but the saved file has no filename (Videos/.mp4).
<?php
$filename = $_POST['filename'];
// File Path to save file
$file = 'Videos/'.$filename.'.mp4';
echo $file;
// Get the Request body
$request_body = @file_get_contents('php://input');
// Get some information on the file
$file_info = new finfo(FILEINFO_MIME);
// Extract the mime type
$mime_type = $file_info->buffer($request_body);
// Logic to deal with the type returned
switch($mime_type)
{
case "video/mp4; charset=binary":
// Write the request body to file
file_put_contents($file, $request_body);
break;
default:
// Handle wrong file type here
}
can anyone help?