Follow the following steps on how to display/show preview of an image file before uploading using jQuery ajax in PHP with MySQL database without refreshing the whole web page: Step 1: Create index.php To Display Image File Upload Form. In this tutorial, we will be using the WAMP server. Step 5 - Create uplaod.php file. Another method called mysql_connect also does the same task, but mysqli_connect is more secure and the i here represents an improved version.. Now let's add the scripts responsible for triggering the file input element and then also displaying the image for preview. I have a little gift for you. This a very basic program, I created this for those people who are beginners and want to learn. The data submitted using the POST method in the HTML form is stored in a variable $filename. specify the encoding type of the form using the,