0

I want to create a function that will receive values as parameters and upload them to a MySQL database. My problem is passing a blob to the function and uploading it to the database. My function currently looks like this:

public function addPost($id,$title,$description,$submitted_by,$screenshot)
{
    $conn = $this->connect(); //connect to the database 

    $sql = "insert into complaint values('null','$title','$description',now(),'0000-00-0000:00:00.000000','$id','$status','$image','$screenshot')";
    $result = mysqli_query($conn,$sql); 

    if($result)
    {
        return true;
    }
    else
    {
        return false; 
    }
}`
PeeHaa
  • 69,318
  • 57
  • 185
  • 258
Sibusiso Shongwe
  • 166
  • 1
  • 2
  • 19

1 Answers1

0

You can use these functions: base64_encode, base64_decode.
And just decoding and encoding blob value

for example:

$encode_image = base64_encode($image);
$sql = "insert into complaint values('null','$title','$description',now(),'0000-00-0000:00:00.000000','$id','$status','$encode_image','$screenshot')";
$result = mysqli_query($conn,$sql); 
mishanon
  • 705
  • 5
  • 11