画像サイズ 1.5MB のアップロード中に警告が表示され、画像がデータベースに保存されませんでした。1MB 未満の画像では問題なく動作します。
これらの警告で数日間立ち往生しているため、助けてください。
これが私のコードです:
<?php
print_r($_FILES);
//connect to the database//
try {
$pdo = new PDO('mysql:host=localhost;dbname=forms1', 'root', 'root',array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
$file = $_FILES['image']['tmp_name'];
$upload=0;
for($count = 0; $count < count($_FILES['image']); $count++)
{
if(!empty($_FILES['image']['name'][$count])){
$image_name[$count] = addslashes($_FILES['image']['name'][$count]); echo '<br \>';
$image_size[$count] = @getimagesize($_FILES['image']['tmp_name'][$count]);
$error[$count] = $_FILES['image']['error'][$count];
if($image_size[$count] == FALSE || ($image_size[$count]) == 0)
echo "That's not an image";
$upload++;
echo $upload;
// Temporary file name stored on the server
$tmpName[$count] = $_FILES['image']['tmp_name'][$count];
// Read the file
$fp[$count] = fopen($tmpName[$count], 'r');
$data[$count] = fread($fp[$count], filesize($tmpName[$count]));
$data[$count] = addslashes($data[$count]);
fclose($fp[$count]);
// Create the query and insert into database.
$stmt = $pdo->prepare('INSERT INTO files (name,image) VALUES (:name,:image)');
$stmt->execute(array('name' => $image_name[$count],'image' => $data[$count]));
if(!$stmt)
echo "Problem uploding the image. Please check your database";
}
}
} catch (PDOException $e) {
print "Error!: " . $e->getMessage();
die();
}
?>
これらは私が得る警告です:
Warning: PDOStatement::execute(): MySQL server has gone away in C:\xampp\htdocs\testing\test.php on line 56
Warning: PDOStatement::execute(): Error reading result set's header in C:\xampp\htdocs\testing\test.php on line 56
この行への警告ポイント:
$stmt->execute(array('name' => $image_name[$count],'image' => $data[$count]));