I am able to insert data from android in MySQL using PHP and JSON, but now I have a difficulty when saving a BLOB type.
I am sure that the PHP script is working fine as I tested it using hardcoded data and the file is saved as BLOB in the database. This is my PHP method:
public function insertBlob($ReportFile,$ReportName,$DateCreated,$UserId){
$blob = fopen($ReportFile,'rb');
$sql = "INSERT INTO Reports (ReportFile,ReportName,DateCreated,UserId) VALUES(:ReportFile,:ReportName,:DateCreated,:UserId)";
$stmt = $this->conn->prepare($sql);
$stmt->bindParam(':ReportFile',$blob,PDO::PARAM_LOB);
$stmt->bindParam(':ReportName',$ReportName);
$stmt->bindParam(':DateCreated',$DateCreated);
$stmt->bindParam(':UserId',$UserId);
return $stmt->execute();
}
Then I am calling this method like this:
insertBlob("$_POST[ReportFile]","$_POST[ReportName]","$_POST[DateCreated]","$_POST[UserId]");
How can I pass data from my Android app to PHP?