Skip to content

Instantly share code, notes, and snippets.

@keedi
Forked from taterbase/upload.php
Created November 15, 2017 07:40
Show Gist options
  • Save keedi/f680b54a122b4c6682eb72bf9f5f7f51 to your computer and use it in GitHub Desktop.
Save keedi/f680b54a122b4c6682eb72bf9f5f7f51 to your computer and use it in GitHub Desktop.
Simple file upload in php
<!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