Hi, how can I upload an image from a local folder to a folder on my server using PHP. I managed to get it to show up in the database with a column called "image" but it doesn't get uploaded to my server files.
I would like images uploaded to my server to be saved in a folder called: /images/
Can somebody help me?
<div class="form-group">
<br><label class="titulos">PORTADA</label><br>
<input type="file" name="image" class="img-upload"></select> <br>
</div>
.
if(!empty($_POST)){
include "connection.php";
$con = connect();
$sql = "insert into post (title,description,image,created_at) value (\"".$_POST["title"]."\",\"".$_POST["description"]."\",\"".$_POST["image"]."\",NOW())";
$con->query($sql);
$last_id = $con->insert_id;
$categorias = get_categorias();
}
Script to upload images through a form and save them on the server using php.
The first thing we have to create a php page including the html tags and within the body create a form as follows:
This form has the action of reloading the page with the POST delivery method and that will allow some type of file to be uploaded. It contains a file-type input that will allow us to select a file from our hard drive and a submit-type button to execute the form.
Pressing the “Upload image” button will be when the php code comes into action that will be in charge of checking and uploading the image to the server if it is correct. This code can go in the same body above the form.
See working example
Source: https://www.jose-aguilar.com/blog/upload-de-imagenes-con-php/ .