Does MySQL BLOB only accept images?
I have been looking online trying to be able to upload larger file sizes of different formats, but I only come across image tutorials.
I have the code below, which fails on the if
statement and returns the echo
when I upload different file types larger than 10 megs. (the column is LONGBLOB
).
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'On'); //On or Off
session_start();
require_once('connect.php');
if(isset($_POST['submit'])){
$file = rand(1000,100000)."-".$_FILES['file']['name'];
$notes = mysqli_real_escape_string($connection,$_POST['notes']);
$file_loc = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$email = mysqli_real_escape_string($connection, $_SESSION['email']);
$folder="uploads/";
move_uploaded_file($file_loc,$folder.$file);
$sql = "INSERT INTO `supportcontent` (`scontentdata`, `scontentnotes`, `suseremail`, `stype`,`ssize`)
VALUES( '$file','$notes','$email','$file_type ','$file_size')";
$current_id = mysqli_query($connection, $sql)
or die("<b>Error:</b> Problem on Image Insert<br/>" . mysqli_error($connection));
if (isset($current_id)) {
header("Location: landingpage.php?upload=success");
}
}
else{
echo 'file is 0';
}
?>