Skip to content

Instantly share code, notes, and snippets.

@albabar
Created August 4, 2014 19:32
Show Gist options
  • Select an option

  • Save albabar/6ff626a7a14cd6f0ae5a to your computer and use it in GitHub Desktop.

Select an option

Save albabar/6ff626a7a14cd6f0ae5a to your computer and use it in GitHub Desktop.
Sometimes it may be needed to test upload on PHP, if it's working. To make the process quicker, this script would help. Just place it in web server root and make sure current folder is writable.
<!DOCTYPE HTML>
<html>
<head><title>Quick Upload for PHP by Babar</title></head>
<body>
<h1>Quick Upload for PHP by <a href="http://www.babar.im">Babar</a></h1>
<?php
if(isset($_FILES['userfile'][)) {
$uploaddir = dirname(__FILE__) . '/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo "<p>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload failed";
}
echo "</p>";
echo '<pre>';
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
}
?>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="512000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
This easy peasy script is by <a href="http://www.babar.im">Babar</a>.
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment