File upload

This commit is contained in:
2021-10-23 18:47:10 +03:00
parent 0c6f9f0aa3
commit 2edb4e445f
5 changed files with 38 additions and 57 deletions

20
upload.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
if (($_FILES['file']['name'] != "")) {
// Where the file is going to be stored
$target_dir = "files/";
$file = $_FILES['file']['name'];
$path = pathinfo($file);
$filename = $path['filename'];
$ext = $path['extension'];
$temp_name = $_FILES['file']['tmp_name'];
$path_filename_ext = $target_dir.$filename.".".$ext;
// Check if file already exists
if (file_exists($path_filename_ext)) {
echo "Sorry, file already exists.";
}else{
move_uploaded_file($temp_name,$path_filename_ext);
echo "Congratulations! File Uploaded Successfully.";
}
}
?>