Я пытаюсь сохранить изображение от пользователя в базе данных, но после вставки он всегда показывает размер изображения как 26B, даже если размер изображения был в Kb. Я взял longBlob в MySQL для хранения того же самого. вот мой код
<input type="file" name="profile_picture" id="imgupload" accept=".jpg,.png,.jpeg">
// for uploading image
$ff_NAME = $_FILES['profile_picture']['name'];
$ff_TMP_NAME = $_FILES['profile_picture']['tmp_name'];
$ff_SIZE = $_FILES['profile_picture']['size'];
$ff_ERROR = $_FILES['profile_picture']['error'];
$ff_TYPE = $_FILES['profile_picture']['type'];
$ffileExt = explode('.',$ff_NAME);
$ffileActualExtention = strtolower(end($ffileExt));
$fallowed = array('png','jpeg','jpg');
if(in_array($ffileActualExtention,$fallowed))
{
if($ff_ERROR===0)
{
if($ff_SIZE<500000)
{
$ffileNameNew = uniqid('',true)."".$ffileActualExtention;
$ffileDestination = 'profileuploads/'.$ffileNameNew;
move_uploaded_file($ff_TMP_NAME,$ffileDestination);
}
else
{
echo 'File size must be less than 500 kb.';
}
}
else
{echo "Error in uploading the files";}
}
else
{echo "Only 'png','jpeg','jpg' are allowed";}
Вставить объявление запроса:
$query = "INSERT INTO detail (`f_profile_picture`) VALUES (?)";
$stmtt = $conn->prepare($query);//prepared statement method
$stmtt->bind_param("s",$ffileNameNew);//binding a parameter to question mark
$stmtt->execute();
if($stmtt->affected_rows > 0)
{
echo("success");
}
else
{
echo("failed");
}