开发者

simple php to return an image returns an error

开发者 https://www.devze.com 2023-01-05 05:20 出处:网络
Trying to simply get an image returned. But the following returns an error \'An error occured.\' Is it possible I need to configure php on my server differently?

Trying to simply get an image returned. But the following returns an error 'An error occured.' Is it possible I need to configure php on my server differently?

if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
// get bytearray
$im = $GLOBALS["HTTP_RAW_POS开发者_Python百科T_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.';


?>


Maybe this helps:

The manual states that it's best to use php://input (man) to read the raw post data. Also, neither $HTTP_RAW_POST_DATA nor php://input will be available with enctype="multipart/form-data".

Ahh... enctype is different from Content-type. Being flash-phobic, I can't guess the inner workings of that actionscript, but this post suggests setting the Enctype header also:

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


grossvogel, in 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");
0

精彩评论

暂无评论...
验证码 换一张
取 消