[英]Input type text is not receiving in php file on submit
I want to send title of the image on submit of form but its not receiving in upload.php i don't know the reason only undefined variable warning is displayed.我想在提交表单时发送图像的标题,但它没有在 upload.php 中接收,我不知道为什么只显示未定义的变量警告。 help anybody.
帮助任何人。
multiupload.php多上传.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
<?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/>';
}
}
}
?>
error/warning:错误/警告:
( ! ) Notice: Undefined index: title in C:\wamp\www\multiple_image_upload\upload.php on line 5
Two reason for this这有两个原因
1)you forget input type for title
in your form 1)您忘记了表单中
title
输入类型
<input type="text" name="title" />
2)May be instead of $_POST['title']
it is 2) 可能不是
$_POST['title']
它是
$_POST['tender']
in your upload.php在你的upload.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.