Flash에서 영화 클립의 '스크린 샷'을 가져 와서 AS Core Lib JPGEncoder 클래스를 사용하여 Jpg로 인코딩 한 다음 POST로 결과 ByteArray를 PHP로 제출하려고합니다. 이미지를 MIME로 인코딩 된 전자 메일에 포함시킵니다.BitmapData from Flash -> PHP ->
현재 Flash에서 인코딩 된 ByteArray를 저장 했으므로 문제가 없으므로 Flash에서 PHP로 전송하는 것이 문제입니다. SwiftMailer를 사용하여 jpeg를 첨부 파일로 사용하여 복잡한 이메일을 보내고 있습니다. 현재 스크립트는 전송 된 데이터에서 첨부 파일을 작성하는 시점에서 충돌하는 것 같습니다.
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) 또는 마임 첨부를 거부합니다. –
'$ image'는'strlen'을 가지고 있습니까? – Charles