Note that there are some explanatory texts on larger screens.

plurals
  1. POBitmapData from Flash -> PHP -> Email
    primarykey
    data
    text
    <p>I'm trying to take a 'screenshot' of a movieclip in Flash, encode it as a Jpg using the AS Core Lib JPGEncoder class, then POST submit the resulting ByteArray to PHP, and embed the image in a MIME encoded email.</p> <p>Currently, I've saved the encoded ByteArray from Flash, and that works fine, so the issue is in the sending from Flash to PHP. I'm using SwiftMailer to send a complex email with the jpeg as an attachment. Currently, the script seems to be crashing at the point where I build the attachment from the sent data.</p> <p>Here's the Actionscript:</p> <pre><code>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"); } </code></pre> <p></p> <p>And here is the PHP:</p> <pre><code>require_once 'lib/swift_required.php'; $image = file_get_contents("php://input"); $attachment = SwiftAttachment::newInstance($image, 'submission.jpg', 'image/jpg');//&lt;--This line stuffs it $message = Swift_Message::newInstance() /*Give the message a subject*/ -&gt;setSubject('Your subject') /*Set the from address with an associative array*/ -&gt;setFrom(array('info@battleforbrisbane.com.au'=&gt;'Battle for Brisbane')) /*Set the to addresses with an associative array*/ -&gt;setTo(array('jordaanm@gmail.com')) /*Give it a body*/ -&gt;setBody('Congratulations! You submission to Battle for Brisbane was received'); $message-&gt;attach($attachment);//&lt;--When the attachment above is commented out, so is this $transport = Swift_SendmailTransport::newInstance(); $mailer = Swift_Mailer::newInstance($transport); $mailer-&gt;send($message); </code></pre> <p>This is for a professional job, so any help would be greatly appreciated.</p> <p><strong>Update: It's not SwiftAttachment, it's Swift_Attachment. Missing underscore, problem solved, application functional. Thanks to all who posted to help me with this</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload