データのバイト配列(そのイメージソース)を他のバールと一緒にサービスに送る必要があります。 私は、次のURLRequestではなくHTTPServiceを使用してデータを送信する必要があります。コンテンツタイプがデータを乱していますか?
var request:URLRequest = new URLRequest ('http://www.mydomain.com/upload.php');
var loader: URLLoader = new URLLoader();
request.contentType = 'application/octet-stream';
request.method = URLRequestMethod.POST;
request.data = byteArrayOfImage;
loader.load(request);
とPHPで
$fp = fopen('myImage.jpg', 'wb');
fwrite($fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ]);
fclose($fp);
のようなものを使用してバイト配列を送信する場合、これは画像の罰金が保存されます。しかし、私は次のものを使用しようとしているので、私は余分なvarsを送信する必要があります。
var service : HTTPService = new HTTPService();
service.method = "POST";
service.contentType = 'application/x-www-form-urlencoded';
service.url = 'http://www.mydomain.com/upload.php';
var variables : URLVariables = new URLVariables();
variables.imageArray = myImageByteArray;
variables.variable2 = "some text string";
variables.variable3 = "some more text";
service.send(variables);
PHP
$byteArray= $_REQUEST["imageArray"];
$fp = fopen('myImage.jpg', 'wb');
fwrite($fp, $byteArray);
fclose($fp);
で次に
しかし、これは動作しません。保存されたファイルのファイルサイズが異なり、後でイメージとして保存されません。 私は何が欠けています。作業中のコンテンツタイプがapplication/octet-streamであり、動作しないコンテンツタイプがapplication/x-www-form-urlencodedですか?