Skip to content

Instantly share code, notes, and snippets.

@MrRaindrop
Created October 11, 2014 14:14
Show Gist options
  • Save MrRaindrop/96309aa248274c96a6eb to your computer and use it in GitHub Desktop.
Save MrRaindrop/96309aa248274c96a6eb to your computer and use it in GitHub Desktop.
php: HTTP_Upload for file uploading
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>testHTTPUpload</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
@require_once("HTTP/Upload.php");
$upload = new HTTP_Upload();
$file = $upload->getFiles('test');
if ($file->isValid()) {
$file->moveTo(__DIR__ . "\\uploads\\");
echo "File successfully uploaded!";
$props = $file->getProp();
echo "<br/>file props: <br/>";
print_r($props);
} else {
$file->errorMsg();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment