This function is used to upload the files. Remember database will only hold the name of the image file and not the file to save the image a particular place we need make a folder named "images" inside your PHP workspace.
It is a predefined function, it takes two parameters.
$_FILES['photo']['tmp_name'] → this takes the picture and stores it in a temporary folder name tmp_name.
Second parameter has a folder named images and name of the picture in variable $pic, this transfers the picture from the temporary folder to the images folder with name as stored in $pic variable.
As the user hit’s the submit button the details should be added to the database and the image must be added to images folder that u created earlier.
Note: In order to send a picture or file we always keep the request POST and enctype as multipart/form-data as we are sending picture as well as the form data with it.
HTML code
Let’s look how the form looks like:
Now make a file named "supplierSubmit.php" and add the following code in it.
PHP code with HTML
This function is used to upload the files. Remember database will only hold the name of the image file and not the file to save the image a particular place we need make a folder named "images" inside your PHP workspace.
It is a predefined function, it takes two parameters.
$_FILES['photo']['tmp_name'] → this takes the picture and stores it in a temporary folder name tmp_name.
Second parameter has a folder named images and name of the picture in variable $pic, this transfers the picture from the temporary folder to the images folder with name as stored in $pic variable.
As the user hit’s the submit button the details should be added to the database and the image must be added to images folder that u created earlier.
Note: In order to send a picture or file we always keep the request POST and enctype as multipart/form-data as we are sending picture as well as the form data with it.
need an explanation for this answer? contact us directly to get an explanation for this answer