In my current code i only insert the filename of the file and the file is stored in a folder. I would also like to store the file in my mysqldatabase. How can i do that.
My table: id file_name fcontent (longblob)
include 'db.php';
if(isset($_FILES['image'])){
    $errors= array();
    $tablename = "files";
    $file_name = $_FILES['image']['name'];
    $file_size =$_FILES['image']['size'];
    $file_tmp =$_FILES['image']['tmp_name'];
    $content =$_FILES['image']['fcontent']; // content in database
    $sql="INSERT INTO $tablename(file_name,content)VALUES('" . mysql_real_escape_string($file_name) . "')"; // here i need to insert the content i assume
    $file_ext=strtolower(end(explode('.',$_FILES['image']['name']))); //convert to lower
$extensions = array("jpeg","jpg","png","txt","html","php","gif");   // File extension that are 
allowed 
if(in_array($file_ext,$extensions )=== false){ // check if value exists in array
     $errors[]="extension not allowed.";
    }
    if($file_size > 2097152){ // cant be greater than 2mb
    $errors[]='File size must be excately 2 MB';
    }               
    if(empty($errors)==true){
        mysql_query($sql);
        move_uploaded_file($file_tmp,"upload/".$file_name); 
        echo "Success";
        header("location:files.php"); // Send back to main page
    }else{
        print_r($errors);
 }
}
?>      
 
     
     
     
     
    