Created
October 11, 2014 14:14
-
-
Save MrRaindrop/96309aa248274c96a6eb to your computer and use it in GitHub Desktop.
php: HTTP_Upload for file uploading
This file contains hidden or 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> | |
<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