I am not able to enter the value of $uploader
variable in mysql query please help me with this. I checked $author
it is getting value with post.
<?php
include("config.php");
$author = $_POST['uname'];
if(isset($_POST['but_upload'])){
$maxsize = 5242880 * 80; // 400MB
$name = $_FILES['file']['name'];
$target_dir = "videos/";
$target_file = $target_dir . $_FILES["file"]["name"];
$uploader = $author;
// Select file type
$videoFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Valid file extensions
$extensions_arr = array("mp4","avi","3gp","mov","mpeg");
// Check extension
if( in_array($videoFileType,$extensions_arr) ){
// Check file size
if(($_FILES['file']['size'] >= $maxsize) || ($_FILES["file"]["size"] == 0)) {
echo "File too large. File must be less than 5MB.";
}else{
// Upload
if(move_uploaded_file($_FILES['file']['tmp_name'],$target_file)){
// Insert record
$query = "INSERT INTO videos(name,location,author) VALUES('$name','$target_file','$uploader')";
mysqli_query($con,$query);
echo "Upload successfully.";
echo $query;
}
}
}else{
echo "Invalid file extension.";
}
}
?>
Result:
INSERT INTO videos(name,location,author) VALUES('$name','$target_file','')