2010-06-16 18:21:58 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Upload a given file into /var/tmp
|
|
|
|
*/
|
|
|
|
$type = $_FILES["file"]["type"];
|
2011-11-23 18:39:33 +00:00
|
|
|
if ($type == "text/plain" || $type == "application/octet-stream" || $type == "application/x-shellscript" || $type == "application/x-sh") {
|
2012-05-04 14:45:17 +00:00
|
|
|
$error = $_FILES["file"]["error"];
|
|
|
|
if ($error) {
|
|
|
|
echo "Return Code: " . $error;
|
|
|
|
} else {
|
|
|
|
$file = $_FILES["file"]["name"];
|
|
|
|
$path = "/var/tmp/" . $file;
|
|
|
|
move_uploaded_file($_FILES["file"]["tmp_name"], $path);
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
// Open and read given file
|
|
|
|
$handler = fopen($path, "r");
|
|
|
|
$data = fread($handler, filesize($path));
|
|
|
|
fclose($handler);
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
// Print out file contents
|
|
|
|
echo $data;
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
// Remove this file
|
|
|
|
unlink($path);
|
|
|
|
}
|
2010-06-16 18:21:58 +00:00
|
|
|
} else {
|
2012-05-04 14:45:17 +00:00
|
|
|
echo "(Error) File type $type not supported";
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|
|
|
|
?>
|