Created
September 23, 2018 17:35
-
-
Save erm3nda/57695494ce8c85e247f7acd2bd34585e to your computer and use it in GitHub Desktop.
1 page PHP upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Upload your files</title> | |
</head> | |
<body> | |
<form enctype="multipart/form-data" action="upload.php" method="POST"> | |
<p>Upload your file</p> | |
<input type="file" name="uploaded_file"></input><br /> | |
<input type="submit" value="Upload"></input> | |
</form> | |
</body> | |
</html> | |
<?PHP | |
if(!empty($_FILES['uploaded_file'])) | |
{ | |
$path = "uploads/"; | |
$path = $path . basename( $_FILES['uploaded_file']['name']); | |
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) { | |
echo "The file ". basename( $_FILES['uploaded_file']['name']). | |
" has been uploaded"; | |
} else{ | |
echo "There was an error uploading the file, please try again!"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment