私のタラの何が問題なのか分かりません。私は私のイメージを提出し、私は成功のポップアップを得るときに私はエラーを取得しないでください。私は私のデータベーステーブルをチェックして画像の名前がアップロードされているかどうかを確認すると、ちょうどIDが挿入されている空白のテーブル行が得られ、それ以外のものはフォルダに画像がありません。もっと見るPrepared Statementsについては画像の名前はデータベースにアップロードされません
<?php
require_once("configur.php");
\t
$mysqli = new mysqli(localhost, root, password, user);
$query_image = 'INSERT INTO shirt_table (images1, images2, images3, images4)
values("' . $_FILES['file1']['name'] . '",
"' . $_FILES['file2']['name'] . '",
"' . $_FILES['file3']['name'] . '",
"' . $_FILES['file4']['name'] . '"
)';
if ($mysqli->query($query_image) === TRUE) {
\t
echo "<script language='javascript'>\n";
echo "alert('Upload successful!')";
echo "</script>\n";
} else {
echo "Error updating record: " . $conn->error;
}
$mysqli->close();
?>
<?php
include("configur.php");
if($_POST)
{
// $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.
if ($_FILES["file1"]["error"] > 0)
{
// if there is error in file uploading
echo "Return Code: " . $_FILES["file1"]["error"] . "<br />";
}
else
{
// check if file already exit in "images" folder.
if (file_exists("shirtimgs/" . $_FILES["file1"]["name"]))
{
}
else
{ //move_uploaded_file function will upload your image.
if(move_uploaded_file($_FILES["file1"]["tmp_name"],"shirtimgs/" . $_FILES["file1"]["name"]))
{
// If file has uploaded successfully, store its name in data base
$query_image = "insert into shirt_table";
if(mysqli_query($link, $query_image))
{
echo "Stored in: " . "shirtimgs/" . $_FILES["file1"]["name"];
}
else
{
echo'';
}
}
}
}
}
?><?php
include("configur.php");
if($_POST)
{
if ($_FILES["file2"]["error"] > 0)
{
// if there is error in file uploading
echo "Return Code: " . $_FILES["file2"]["error"] . "<br />";
}
else
{
// check if file already exit in "images" folder.
if (file_exists("shirtimgs/" . $_FILES["file2"]["name"]))
{
}
else
{ //move_uploaded_file function will upload your image.
if(move_uploaded_file($_FILES["file2"]["tmp_name"],"shirtimgs/" . $_FILES["file2"]["name"]))
{
// If file has uploaded successfully, store its name in data base
$query_image = "insert into shirt_table";
if(mysqli_query($link, $query_image))
{
echo "Stored in: " . "shirtimgs/" . $_FILES["file2"]["name"];
}
else
{
echo'';
}
}
}
}
}
?><?php
include("configur.php");
if($_POST)
{
// $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.
if ($_FILES["file3"]["error"] > 0)
{
// if there is error in file uploading
echo "Return Code: " . $_FILES["file3"]["error"] . "<br />";
}
else
{
// check if file already exit in "images" folder.
if (file_exists("shirtimgs/" . $_FILES["file3"]["name"]))
{
}
else
{ //move_uploaded_file function will upload your image.
if(move_uploaded_file($_FILES["file3"]["tmp_name"],"shirtimgs/" . $_FILES["file3"]["name"]))
{
// If file has uploaded successfully, store its name in data base
$query_image = "insert into shirt_table";
if(mysqli_query($link, $query_image))
{
echo "Stored in: " . "shirtimgs/" . $_FILES["file3"]["name"];
}
else
{
echo'';
}
}
}
}
}
?><?php
include('configur.php');
if($_POST)
{
// $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.
if ($_FILES["file4"]["error"] > 0)
{
// if there is error in file uploading
echo "Return Code: " . $_FILES["file4"]["error"] . "<br />";
}
else
{
// check if file already exit in "images" folder.
if (file_exists("shirtimgs/" . $_FILES["file4"]["name"]))
{
}
else
{ //move_uploaded_file function will upload your image.
if(move_uploaded_file($_FILES["file4"]["tmp_name"],"shirtimgs/" . $_FILES["file4"]["name"]))
{
// If file has uploaded successfully, store its name in data base
$query_image = "insert into shirt_table";
if(mysqli_query($link, $query_image))
{
echo "Stored in: " . "shirtimgs/" . $_FILES["file4"]["name"];
}
else
{
echo'';
}
}
}
}
}
?>
<form id="myform" action='https://website.com/results' method="POST">
<input type="file" name="file3" id="file3" required formvalidate>
<input type="file" class="upload-img" name="file1" id="file1" onchange="readURL(this);" />
<input type="file" class="upload-img2" name="file2" id="file2" onchange="readURL(this);" />
<input type="file" class="upload-img3" name="file4" id="file4" onchange="readURL(this);" />
<input type="submit" name="submit" value="Submit" />
複数のファイルをアップロードしようとしていますか?私はあなたが1つのファイルのアップロードを処理することを見ることができますが、複数のクエリがあることを示しています...明確にしてください。 –
エラーログを確認しましたか? PHP環境で 'display_errors'が有効になっていますか? –
@Magnus Erikssonはい複数のファイルをアップロードしようとしていますが、わかりやすいように投稿しただけです – user7368271