mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-11-03 12:52:37 +00:00 
			
		
		
		
	git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12434 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
		
			
				
	
	
		
			29 lines
		
	
	
		
			830 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			830 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * Upload a given file into /var/tmp
 | 
						|
 */
 | 
						|
$type = $_FILES["file"]["type"];
 | 
						|
if ($type == "text/plain" || $type == "application/octet-stream" || $type == "application/x-shellscript" || $type == "application/x-sh") {
 | 
						|
    $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);
 | 
						|
 | 
						|
        // Open and read given file
 | 
						|
        $handler = fopen($path, "r");
 | 
						|
        $data = fread($handler, filesize($path));
 | 
						|
        fclose($handler);
 | 
						|
 | 
						|
        // Print out file contents
 | 
						|
        echo $data;
 | 
						|
 | 
						|
        // Remove this file
 | 
						|
        unlink($path);
 | 
						|
    }
 | 
						|
} else {
 | 
						|
    echo "(Error) File type $type not supported";
 | 
						|
}
 | 
						|
?>
 |