In this image upload in php code with databases article, i make a HTML form that takes user profile an image as well as some users bio text. When the user selects any your profile an image and enters some Bio text and then simply clicks the submit button, the all the users data is submitted to the server side and save MySQL Database. PHP now grabs the image as well as saves it in a folder in the main upload project, and then saves the text in the mysql database together with a link pointing to the image in the profiles folder.
How to Upload Image into Database and Display it using PHP ?
Create a database called users_master and make a mysql table called users profiles with some added fields like as image type, file name, size or many more:
Also Read: Multiple Image Upload using PHP into MYSQL database
- id – int(11)
- image – varchar(255)
- file_imag_name – text
Make a file called profile.php and page the following code in it (the complete code):
profile.php:
- Make database connection
- Initialize message variable
- If upload button is clicked
- Get image name
- Get text
- image file directory
- execute query
Image Upload "; echo ""; echo ""; } ?>".$row['file_imag_name']."
"; echo "