我想發送圖像的字節數組到我的web服務在json object.But,它的請求永遠不會打我的服務器。如果我只發送一個空數組,它會觸發服務器並返回json響應。以下是我的代碼。此代碼有什麼問題如何發送來自php的字節數組
<?php
header('Content-type: application/json');
//Read an image from third party URL
$contents= file_get_contents('http://i2.cdn.turner.com/cnn/dam/assets/120612031415-granderson-speech-c1-main.jpg');
$byteArr = str_split($contents);
foreach ($byteArr as $val)
{
$points[] = ord($val);
}
$output = join (" " , $points);
//echo($output);
//If i use "photo"=>[] in below array it works fine
$jsonArray = array("comments"=>"Hiee", "type"=>"test", "photo"=>[$output],"custid"=>"[email protected]");
$buzz = json_encode($jsonArray);
try {
//Webservice call to store the image in DB and send mail
$jsonResponse = @file_get_contents("http://localhost/example/json.htm?action=sendBuzzRequest&[email protected]&pass=test1234&buzz=".$buzz);
echo ($jsonResponse);
} catch(Exception $e)
{
$e->getMessage();
}
?>
您的幫助是非常感謝。
您可能達到了GET請求的最大尺寸..這種規格看起來更適合POST或PUT請求.. – Ben
和事實比空數組作品似乎很難她確認假設.. – Ben
GET大小限制的另一個相關條目... http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request – Ben