Skip to content

Instantly share code, notes, and snippets.

@MrRaindrop
Created October 11, 2014 01:06
Show Gist options
  • Save MrRaindrop/36a930d99135654e33b6 to your computer and use it in GitHub Desktop.
Save MrRaindrop/36a930d99135654e33b6 to your computer and use it in GitHub Desktop.
php: upload file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>testUpload</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"
enctype="multipart/form-data">
<br/>upload file:
<br/><input type="file" name="test" />
<br/><input type="submit" value="submit" />
</form>
</body>
</html>
<?php
if (isset($_FILES['test'])) {
// if (is_uploaded_file($_FILES['test']['tmp_name'])) {
// copy($_FILES['test']['tmp_name'], __DIR__ . "\\uploads\\" . $_FILES['test']['name']);
// } else {
// echo "<p>Potential script abuse attempt detected.</p>";
// }
move_uploaded_file(
$_FILES['test']['tmp_name'],
__DIR__. "\\uploads\\" . $_FILES['test']['name']
);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment