私はPHPとMySQLを使用して画像をアップロードしようと下記の使用コード..ですmove_upload_fileが指定されたコードで常にfalseを返すのはなぜですか?
のindex.php
<form action="submit.php" enctype="multipart/form-data" method="post">
<table style="border-collapse: collapse; font: 12px Tahoma;" border="1" cellspacing="5" cellpadding="5">
<tbody><tr>
<td>
<input name="uploadedimage" type="file">
</td>
</tr>
<tr>
<td>
<input name="Upload Now" type="submit" value="Upload Image">
</td>
</tr>
</tbody></table>
</form>
submit.php
<?php
include("mysqlconnect.php");
function GetImageExtension($imagetype) {
if (empty($imagetype))
return false;
switch ($imagetype) {
case 'image/bmp': return '.bmp';
case 'image/gif': return '.gif';
case 'image/jpeg': return '.jpg';
case 'image/png': return '.png';
default: return false;
}
}
if (!empty($_FILES["uploadedimage"]["name"])) {
$file_name = $_FILES["uploadedimage"]["name"];
$temp_name = $_FILES["uploadedimage"]["tmp_name"];
$imgtype = $_FILES["uploadedimage"]["type"];
$ext = GetImageExtension($imgtype);
$imagename = date("d-m-Y") . "-" . time() . $ext;
$target_path = "images/" . $imagename;
if (move_uploaded_file($_FILES['uploadedimage']['tmp_name'], $target_path)) {
$detail = date("Y-m-d");
$sql = "INSERT INTO `image_upload`(`id`, `image`, `detail`) VALUES (NULL,'$target_path','$detail')";
if (!$conn->query($sql)) {
echo $conn->error;
} else {
echo "Successfully inserted. ";
}
} else {
exit("Error While uploading image on the server");
}
}
?>
表構造います:
# Name Type Collation Attributes Null Default Extra
1 id(Primary) int(11) No None AUTO_INCREMENT
2 image blob Yes NULL
3 detail varchar(500) utf8_general_ci Yes NULL
これを実行するたびに、常に「エラーサーバー上に画像をアップロードしている間に "私は理由を理解していません。誰かが私に間違っていることを教えてもらえますか?どのように実装を改善できますか? ありがとうございます。
を動作するかどうか、あなたのディレクトリを確認するチェックが存在したりせず、ディレクトリへ –
権限がすでにまだそれが実行されない与えられて書き込み権限を持っています。 –