【发布时间】:2018-07-28 16:30:40
【问题描述】:
大家好,当我转到联系人 php 表单时,我正在尝试查看是否可以一次从我的联系人 php 表单接收多张照片到我的雷鸟电子邮件我单击选择文件并突出显示要发送的照片将显示已选择的 13 张照片,然后我提交了包含这些照片的表格,然后我检查了我的雷鸟电子邮件,我只收到了一张照片。我附上了我的联系表格的 2 个屏幕截图,其中包含选择的 13 张照片和我收到的带有一张照片附件的电子邮件,而且我已经包含了联系表格中的 php 代码任何想法,因为这可能是什么问题任何帮助和解决方案都非常重要非常感谢提前感谢。
<?PHP
/*
Contact Form from HTML Form Guide
This program is free software published under the
terms of the GNU Lesser General Public License.
See this page for more info:
http://www.html-form-guide.com/contact-form/contact-form-attachment.html
*/
require_once("./include/fgcontactform.php");
$formproc = new FGContactForm();
//1. Add your email address here.
//You can add more than one receipients.
$to = $formproc->AddRecipient('test@alphaboss.ca'); //<<---Put your email
address here
$subject = 'Form was submitted';
$message = 'New message from a visitor';
$headers = 'From: test@alphaboss.ca' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers); // 'test@alphaboss.ca', 'Form was
submitted', 'New message from a visitor'
//2. For better security. Get a random tring from this link:
// and put it here
$formproc->SetFormRandomKey('HG9hPBpn9Bn26yg');
$formproc->AddFileUploadField('photo','jpg,jpeg,gif,png,bmp',2024);
if(isset($_FILES ['name']))
if(isset($_FILES ['photo']))
if(count($_FILES['name']['photo'])) {
foreach ($_FILES['name']['photo'] as $file) {
// Count total files
$formproc = count($_FILES['photo']['name']);
}
// Looping all files
for($i=0;$i<$fromproc;$i++){ $file = $_FILES['photo']['name'][$i];
}
// Upload file
move_uploaded_file($_FILES['photo']['tmp_name'][$i],'submit/'.$file);
//do your upload stuff here
echo $file;
}
}
if(isset($_POST['submitted']))
{
if($formproc->ProcessForm())
{
$formproc->RedirectToURL("thank-you.php");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Alpha Boss Computer Services</title>
<style>
body {font-family: Verdana, sans-serif;
margin: 0;
}
h1 {text-align:center;
color: navy;
}
#background-image {
background-image: url(alpha.png);
width: 100%;
top: 0;
left: 0;
height:100%;
opacity: 0.2;
position: absolute;
background-repeat: repeat;
padding: 0;
margin: 0;
z-index:0;
}
.navbar {
overflow: hidden;
background-color: #333;
position: fixed;
bottom: 0;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.navbar a {
display: inline-block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
margin: 0px auto;
}
.navbar a:hover {
background: #f1f1f1;
color: black;
}
.fieldset-auto-width {
display: inline-block;
}
form {
position: absolute;
z-index: 2;
left: 50px;
right: 50px;
}
</style>
<link rel="STYLESHEET" type="text/css" href="contact.css" />
<script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
<script type='text/javascript' src='scripts/fg_captcha_validator.js'>
</script>
<link rel="icon" href="http://localhost/alpha.png" type="image/png"
sizes="16x16">
</head>
<body>
<div id="background-image"></div>
<!-- Form Code Start -->
<center><form id='contactus' action='<?php echo $formproc->GetSelfScript();
?>' method='post' enctype="multipart/form-data" accept-charset='UTF-8'>
<fieldset class="fieldset-auto-width">
<legend><h1>Contact Alpha Boss Computer Services</h1></legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>'
value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text' class='spmhidip' name='<?php echo $formproc-
>GetSpamTrapInputName(); ?>' />
<div class='short_explanation'><font size="3" color="navy"><h1>* required
fields</h1></font></div>
<div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span>
</div>
<div class='container'>
<label for='name'><font size="3" color="navy"><h1>Your Full Name Below*:
</h1></font></label><br/>
<input style='width:400px;height:40px;font-size:14pt; border:3px solid
black' type='text' name='name' id='name' value='<?php echo $formproc-
>SafeDisplay('name') ?>' maxlength="50" /><br/>
<span id='contactus_name_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='email'><font size="3" color="navy"><h1>Your Email Address
Below*:</h1></font></label><br/>
<input style='width:400px;height:40px;font-size:14pt; border:3px solid
black' type='text' name='email' id='email' value='<?php echo $formproc-
>SafeDisplay('email') ?>' maxlength="50" /><br/>
<span id='contactus_email_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='message'><font size="3" color="navy"><h1>Your Message Below:
</h1></font></label><br/>
<span id='contactus_message_errorloc' class='error'></span>
<textarea rows="10" cols="50" name='message' id='message' style="border:3px
solid black"><?php echo $formproc->SafeDisplay('message') ?></textarea>
</div>
<div class='container'>
<label for='photo'><font size="3" color="navy"><h1>Upload your photos:</h1>
</font></label><br/>
<input type="file" name='photo[]' id='photo' multiple=""/><br/>
</div>
<div class='container'>
<input type='submit' name='Submit' value='Submit' />
</div>
</fieldset>
</form></center>
<h1>You can call <u>289-696-7530</u></h1>
<div class="navbar">
<div class="navbar-inner">
<a href="index.html">HOME</a>
<a href="https://www.facebook.com/Alpha-Boss-Computer-Services-
1259286717548256/">FACEBOOK PAGE</a>
</div>
</div>
<!-- client-side Form Validations:
Uses the excellent form validation script from JavaScript-coder.com-->
<script type='text/javascript'>
// <![CDATA[
var frmvalidator = new Validator("contactus");
frmvalidator.EnableOnPageErrorDisplay();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email
address");
frmvalidator.addValidation("email","email","Please provide a valid email
address");
frmvalidator.addValidation("message","maxlen=2048","The message is too long!
(more than 2KB!)");
frmvalidator.addValidation("photo","file_extn=jpg;jpeg;gif;png;bmp","Upload
images only. Supported file types are: jpg,gif,png,bmp");
// ]]>
</script>
</body>
</html>
@Wr1t3r 这是我更新的 fgcontactform.php 代码我希望这有助于你更好地理解。我还收到了http://www.html-form-guide.com/contact-form/contact-form-attachment.html的联系表格。
【问题讨论】: