I am trying to send a ByteArray to PHP which will then store it as a BLOB in my database. When I trace the ByteArray I get a length of 24,000 bytes which is good. When I send it to the database it appears something is not working right because when I return the database value I always get a length of 10. I made sure the table value is set at MEDIUM BLOB.
Here is my code in AS3:
var jpg:JPGEncoder = new JPGEncoder(70);
var byteArray:ByteArray = jpg.encode(cropData);
var phpVars:URLVariables = new URLVariables();
var phpFileRequest:URLRequest = new URLRequest("http://");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.BINARY;
phpLoader.addEventListener(Event.COMPLETE, confirmUpload);
//phpVars.systemCall = "pullProfile";
phpVars.picArray = byteArray;
phpLoader.load(phpFileRequest);
Here is my code in PHP:
<?php
include_once("connect.php");
$loggeduserapp = $_POST['loggeduserapp'];
$picArray = $_POST['picArray'];
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE athletes.userinfo SET profilepicture='$picArray' WHERE email='$loggeduserapp'";
$conn->exec($sql)
?>
Perhaps I am loading the BLOB information the wrong way? Right now, I have it in a JSON Object because I am reading other information as well for the user and I am referencing it like this.
var pbyteArray:ByteArray = new ByteArray();
trace(profileArray.profilepicture); //profileArray is my JSON Object
pbyteArray.writeObject(profileArray.profilepicture);
trace(pbyteArray.length);
I'm not sure what to do at this point, any help is much appreciated. Thanks!