Upload data to PDO MySQL Blob column

Part 1 Managing Blob data type
Upload to MySQL  Blob

User upload binary data or image to store in MySQL BLOB data type column using PHP PDO

Displaying the uploading form.
BLOB: binary large object
User will enter the name of the Student ( t1 ) , Select one of the available ID (id ) and choose the file to upload by using file browser.
echo "<form action='uploadck.php' method=post 
	enctype='multipart/form-data' >
Name : <input type=text name=t1><br>
Select one ID :<select name=id>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
Upload this file: <input type=file name='file_up'>
<input type=submit value='Upload Image'></FORM>";

Processing the uploaded data with image.

Data is collected by using POST method. config.php is the database connection file. After upload, the image is available as $_FILES[file_up][tmp_name].
require 'config.php'; // database connection file. 
require 'menu.php';
$photo= fopen($_FILES[file_up][tmp_name], 'rb');
$query="insert into student_profile(id,student,profile_photo)
$step->bindParam(':id',$id,PDO::PARAM_INT, 3);
$step->bindParam(':student',$student,PDO::PARAM_STR, 10);

echo " Data with Photo is added ";
echo " Not able to add data please contact Admin ";
PDO Blob column adding , updating & displaying records
PDO References rowcount()

Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer