我创建了一个非常简单的 PHP 文件,它完成了非常简单的工作,它将图像从 Silverlight OutOfBrowser 应用程序流式传输到服务器,它在$_GET
和$_POST
变量之间混合,事实上这是我非常简单的代码,我知道它缺乏安全,但我还是写了它只是为了确保我可以通过网络写入文件,并且它可以 100% 地上传多个文件等。
<?php
//Gets
$myFile = $_GET['FileName'] ? $_GET['FileName'] : "input_stream.txt";
$openedFile = fopen($myFile, 'w') or die("can't open file");
$input = file_get_contents("php://input");
fwrite($openedFile, $input);
fclose($openedFile);
//Check the mime type of the file (WRONG WAY)
$mimeType = mime_content_type($myFile);
$input = null;
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimeType = finfo_file($finfo, $myFile);
echo $myFile . 'was uploaded, mime type : ' . $mimeType;
?>
那么是否有任何简单的 Ruby 替代方法来获取原始 POST 数据(这将是 Silverlight 的 ByteArray)?