How to Upload Image into Database and Display it using PHP

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone in this video we will upload an image and we will display that using PHP okay we will upload that to the database to the main SQL and we will display that back using PHP so I have installed the exam server and there's some server the Apache in MySQL is running and let's come to the localhost and PHP my admin okay and we will create a table and then we will sit let's come to the crowd I will create a table here let's create a table images and the column name should be we have two columns in this let's go and the First Column would be the ID integer that should be add to increment and the second tower column would be image or we can see file it should be worker and the link should be for example 50 and let's go and save this yeah we have this table now so now let's go to our Visual Studio code I have created a folder in HD Docs C to the sum folder into the HT docs and then in the page and this table I have these two file uploading connection first we will create our connection so to create our connection let's start our HP script connection is equal to my SQL I connect and the first thing is the server that is localhost second one is the user which is root the password we didn't see it and the DB the DB name is cracked let's say equal to false we should die connection error that should be my SQL I connect error now we will first we will create a forum here we should have a four input field type should be text find sorry and name is equal to image let's um we would like to overwrite our PHP script in the same file so we don't need action so I will like the method which is post and also ink type for the file uploading multiple oh sorry 24 form data so let's create a button float type is equal to submit and then the name is so now we will display our form here under this so first I will upload for the image inside our PHP script for seven um import or include the connection dot PHP after that I will just stick if the Forum was submitted if she post submit is the Forum is submitted so then I will execute this the following code first I will get the file is equal to files and file name is image with us and get the name of that it is file name all right our temp name is equal to files image and also team mp10 name in the folder where we would like to store our image so we would like to create a folder in this switch folder let's name it images okay we will upload our files here so I will write Images slash dot the file name okay the file we have uploaded yeah this one so now we will run our query to insert the image to the database query is equal to My Secret Life Theory the first thing we should write the connection name okay we have created here and we imported this connection and second one was between write our query in there into the the table name was image I think let's check that images and I will just enter the uh file values file name so now we will upload it to the folder okay to upload that to the folder we will just come right here through Mo uploaded file and the first thing is that right our 10th name and the second thing is sorry you should try temp name and the second thing is the um folder so if it has uploaded so we will find some message 4D elves fine art upload it after uploading the files you know we will display that we can we will not design it okay we'll just display that so here first of all we will write the five of this folder images we will fix now the I made its name from the database so to fix that let's write and open our PHP script so we will run our query first result is equal to mySQL and clearing the first we will pass the connection the new Light Select direct from my images we'll just try to while look row is equal to my sqli P2 again I will pass the result it's right here the eco row and the name of the image that was filed in the database so now let's close back the PHP the while loop so okay it all everything is okay so now let's run our server localhost and we will go to fetch folder in which folder we will go to upload and upload right now we don't have any image and let's submit of an image for example this one place the submit button yeah see it file uploaded successfully and we have the image here if we upload another one let's for example this one and submitted file upload it see both files are this looking the first one card operation of hpn a big data of my screen PHP so it was you can design it okay I have just upload it and show you the functionality using PHP you know with mySQL to upload an image or file and display that back on the browser so it was all about this functionality so if you haven't liked this video subscribe our YouTube channel and thanks for watching
Info
Channel: Code With Yousaf
Views: 37,840
Rating: undefined out of 5
Keywords: upload files and images to website in php, upload image in php mysql, upload a file to mysql database using php, how to insert image into database using php, upload image in php mysql database and display, how to upload image using php and mysql, image upload in php, image upload in php mysql database, image upload in php code with databases, upload and display image in php, how to insert image into database in php, how to upload image to mysql database and display it using php
Id: 6iERr1ADFz8
Channel Id: undefined
Length: 10min 50sec (650 seconds)
Published: Tue Feb 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.