简单的PHP返回图像返回错误

时间:2010-06-25 15:35:16

标签: php httpwebrequest

尝试简单地返回图像。但是以下内容会返回错误“发生错误”。是否有可能我需要在我的服务器上配置不同的PHP?     

if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
// get bytearray
$im = $GLOBALS["HTTP_RAW_POST_DATA"];

// add headers for download dialog-box
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $im;
}  else echo 'An error occured.';


?>

2 个答案:

答案 0 :(得分:1)

也许这会有所帮助:

The manual声明最好使用php://input (man)来阅读原始帖子数据。此外,$HTTP_RAW_POST_DATAphp://input都不可用enctype="multipart/form-data"

啊...... enctypeContent-type不同。由于闪光恐惧症,我无法猜测该动作内容的内部运作,但this post建议设置Enctype标题:

jpgURLRequest.requestHeaders.push(new URLRequestHeader('Enctype', 'application/x-www-form-urlencoded');

答案 1 :(得分:0)

grossvogel,在Actionscript中

var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest ("myPHPthatisbroken.php?name=myreturnedJpg.jpg");
jpgURLRequest.requestHeaders.push(header);  
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
navigateToURL(jpgURLRequest, "_blank");