私はFlashでムービークリップの 'screenshot'を取って、AS Core Lib JPGEncoderクラスを使ってJpgとしてエンコードしてから、結果のByteArrayをPHPに送信します。イメージをMIMEでエンコードされた電子メールに埋め込みます。BitmapData from Flash - > PHP - >メール
現在のところ、FlashからエンコードされたByteArrayを保存していますが、正常に動作するため、FlashからPHPへの送信に問題があります。 SwiftMailerを使用してjpegを添付ファイルとして複合メールを送信しています。現在、送信されたデータから添付ファイルを作成する時点で、スクリプトがクラッシュしているようです。ここで
は、ActionScriptです:
trace("Sending Email");
var rootMC:MovieClip = MovieClip(root);
var data1:BitmapData = new BitmapData(rootMC.width, rootMC.height);
data1.draw(rootMC);
var en:JPGEncoder = new JPGEncoder(80);
var bArray:ByteArray= en.encode(data1);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var request:URLRequest = new URLRequest();
request.requestHeaders.push(header);
request.url = mailLoc;//MailLoc is the URL of the PHP.
request.method = URLRequestMethod.POST;
request.data = bArray;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE, MailCompleteHandler);
try
{
loader.load(request);
}
catch(error:Error)
{
trace("Unable to load URL");
}
そして、ここではPHPです:
require_once 'lib/swift_required.php';
$image = file_get_contents("php://input");
$attachment = SwiftAttachment::newInstance($image, 'submission.jpg', 'image/jpg');//<--This line stuffs it
$message = Swift_Message::newInstance()
/*Give the message a subject*/
->setSubject('Your subject')
/*Set the from address with an associative array*/
->setFrom(array('[email protected]'=>'Battle for Brisbane'))
/*Set the to addresses with an associative array*/
->setTo(array('[email protected]'))
/*Give it a body*/
->setBody('Congratulations! You submission to Battle for Brisbane was received');
$message->attach($attachment);//<--When the attachment above is commented out, so is this
$transport = Swift_SendmailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$mailer->send($message);
は、これがプロの仕事のためなので、任意の助けをいただければ幸いです。
更新:SwiftAttachmentではなく、Swift_Attachmentです。不足しているアンダースコア、問題解決、アプリケーション機能
これは[昨日あなたの質問の正確な重複](http://stackoverflow.com/questions/5399235/bitmapdata-from-flash-to-php-to-email)と思われます。私はまだ1x1 GIFの生の出力を見ることが大好きですが、ここではありません。 – Charles
これは昨日の質問の洗練されたバージョンです。マイナーな問題のいくつかは自分で解決しました(手動でエンコードする代わりにSwiftMailerを使用)。しかし、大きな問題は終了していません。 1x1ピクセルの点では、Flash-> PHPから送信されるデータは、書き込み(fwrite)またはMIME接続を拒否します。 –
'$ image'は' strlen'を持っていますか? – Charles