// This code helps me submit a picture into my images folder. However the file keeps its original name because of the function basename. How can I add a specific name to the file? Like logo.png?
<?php
if(isset($_POST['submit'])) {
//PROCESS FORM DATA
$tmp_file = $_FILES['file_upload']['tmp_name'];
$target_file = basename($_FILES['file_upload']['name']);
$upload_dir = "images";
//Move file
//False als die niet correct is
if (move_uploaded_file($tmp_file, $upload_dir."/".$target_file)) {
$message = "File upload succesfull";
} else {
$error = $_FILES['file_upload']['error'];
$message = $upload_errors[$error];
}
}
?>
Html form:
<form action="upload_logo.php" enctype="multipart/form-data" method="POST">
Select .png logo to upload:
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<input type="file" name="file_upload" />
<input type="submit" name="submit" value="Upload" />
</form>