Я хочу отправить заголовок изображения при отправке формы, но он не получен в upload.php. Не знаю, почему отображается только неопределенное предупреждение о переменной. помогите никому.
multiupload.php
<!DOCTYPE html>
<html>
<head>
<title>Upload Multiple Images Using jquery and PHP</title>
<!-------Including jQuery from google------>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="script.js"></script>
<!-------Including CSS File------>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<div id="maindiv">
<div id="formdiv">
<h2>Multiple Image Upload Form</h2>
<form enctype="multipart/form-data" action="" method="post">
First Field is Compulsory. Only JPEG,PNG,JPG Type Image Uploaded. Image Size Should Be Less Than 100KB.
<hr/>
<input type="text" name="title" />
<div id="filediv"><input name="file[]" type="file" id="file"/></div><br/>
<input type="button" id="add_more" class="upload" value="Add More Files"/>
<input type="submit" value="Upload File" name="submit" id="upload" class="upload"/>
</form>
<br/>
<br/>
<!-------Including PHP Script here------>
<?php include "upload.php"; ?>
</div>
<!-- Right side div -->
<div id="formget"><a href=http://www.formget.com/app><img src="formget.jpg" alt="Online Form Builder"/></a>
</div>
</div>
</body>
</html>
upload.php
<?php
if (isset($_POST['submit'])) {
echo 'hell';
$j = 0; //Variable for indexing uploaded image
$value = isset($_POST['title']) ? $_POST['title'] : '';
echo 'title:'.$value;
$target_path = "uploads/"; //Declaring Path for uploaded images
for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array
$ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.)
$file_extension = end($ext); //store extensions in the variable
if( move_uploaded_file($_FILES["file"]["tmp_name"][$i], $target_path . $_FILES["file"]["name"][$i])){
echo ($i+1).')'. $_FILES["file"]["name"][$i]. '.<span id="noerror">is uploaded successfully!.</span><br/><br/>';
} else {//if file was not moved.
echo $i. ').<span id="error">please try again!.</span><br/><br/>';
}
}
}
?>
Ошибка / предупреждение:
( ! ) Notice: Undefined index: title in C:\wamp\www\multiple_image_upload\upload.php on line 5
Две причины для этого
1) вы забыли тип ввода для title
в твоей форме
<input type="text" name="title" />
2) Может быть вместо $_POST['title']
это
$_POST['tender']
в вашем upload.php
Других решений пока нет …