In my PHP application, users can choose to upload a file and this file will be stored in a table in my MySQL database.
On my XAMPP on Windows instance, this works fine. However, on AWS EC2 Ubuntu, when the form is submitted with a selected file, the web browser comes up with "Server Error 500 The website encountered an error while retrieving. It may be down for maintenance or configured incorrectly."
I initially checked the my.cnf
file for the max_allowed_packet
size, but this seems to fine as it was at default set to 16MB, however I have a feeling it's do with the Apache server itself not liking the upload of BLOBs.
Here is the PHP code that deals with inserting BLOBs to the table:
//execute stored proc. to upload attachment
$null = null;
$query = $this->connection->prepare("CALL sp_PopulateAbstractAttachments(?,?,?,?,?)");
$query->bind_param("ibssi", $abstractID, $null, $name, $type, $size) or die(mysqli_error($this->connection));
foreach (str_split($attachment, 10240) as $chunk)
{
$query->send_long_data(1, $chunk);
}
$query->execute() or die(mysqli_error($this->connection));
$query->close();
Like I said, this works perfectly fine on XAMPP Windows, but not on AWS EC2 Ubuntu. What could be causing this issue?
EDIT
According to Apache's error log, this is the problem:
[Thu Jan 07 19:24:24.571319 2016] [:error] [pid 12049] [client XXX.XXX.XXX.XXX:XXXXX] PHP Fatal error: Call to a member function bind_param() on a non-object in /var/www/html/app/models/Abstracts.php on line 40, referer: http://XXXXXXXXXXX/public/index.php?url=home/submitAbstract/
What could the issue be?