我设计了这个表单,并且不知道如何用php连接它以通过电子邮件发送数据。上传文件必须为jpeg,大小不得超过30kb。你能帮帮我吗?
<!doctype html>
<html lang="en">
<head>
<title>application form</title>
</head>
<body>
<form method="post" action="submit.php">
<input type="text" name="fstname" placeholder="First Name"><br>
<input type="text" name="lstname" placeholder="Last Name"><br>
<input type="text" name="faname" placeholder="Father's Name"><br>
<input type="text" name="maname" placeholder="Mother's Name"><br>
<input type="tel" name="mobile" placeholder="Mobile No."><br>
<input type="tel" name="phone" placeholder="Phone No."><br>
<input type="email" name="email" placeholder="Email ID"><br>
<input type="text" name="adrs" placeholder="Pemanent Address" maxlength="250"><br>
<input type="text" name="cnt" placeholder="Country"><br>
<input type="text" name="pin" placeholder="Pin Code"><br>
<input type="text" name="adrs2" placeholder="Present Address" maxlength="250"><br>
<input type="text" name="cnty" placeholder="Country"><br>
<input type="text" name="zip" placeholder="Pin Code"><br>
<fieldset>
<legend>What is Your Gender?</legend>
<input type="radio" name="gen" value="male" checked />Male
<input type="radio" name="gen" value="female" />Female
<input type="radio" name="gen" value="other" />Other
</fieldset>
<fieldset>
<legend>What is Your Religon</legend>
<input type="radio" name="rel" value="hindu" checked />Hindu
<input type="radio" name="rel" value="muslim" />Muslim
<input type="radio" name="rel" value="christian" />Christian
<input type="radio" name="rel" value="other" />Other
</fieldset>
<fieldset>
<legend>Are you physically challenged?</legend>
<input type="radio" name="cha" value="no" checked />No
<input type="radio" name="cha" value="yes" />Yes
</fieldset>
<fieldset>
<legend>Choose the Training Method.</legend>
<input type="radio" name="tm" value="ait" checked />AIT
<input type="radio" name="tm" value="its" />ITS
<input type="radio" name="tm" value="mes" />MES
<input type="radio" name="tm" value="aajee" />AAJEEVIKA
<input type="radio" name="tm" value="sch" />SCHEME
<input type="radio" name="tm" value="dass" />DIRECT ASSESSING
<input type="radio" name="tm" value="ot" />OTHER
</fieldset><br>
<input type="text" name="cmt" placeholder="Community"><br>
<input type="text" name="edu" placeholder="Education"><br>
<input type="text" name="oq" placeholder="Other Qualifications"><br>
<span>Following files be attached in jpeg format, size no more than 30kb</span><br>
<input type="file" value="sign"> Signature File.<br>
<input type="file" value="tc"> TC Copy.<br>
<input type="file" value="ms1"> Marksheet Copy 1.<br>
<input type="file" value="ms2"> Marksheet Copy 2.<br>
<input type="file" value="oq1"> Other Qualification Copy 1.<br>
<input type="file" value="oq2"> Other Qualification Copy 2.<br>
<input type="file" value="cc"> Community Certificate Copy.<br>
<input type="file" value="adrsp"> Address Proof Copy.<br>
<input type="file" value="adar"> Adhar Card Copy.<br>
<input type="reset"> <input type="submit" value="Submit">
</form>
</body>
</html>
&#13;
答案 0 :(得分:0)
这就是:
将您的HTML设为:
<input name="upload[]" type="file" multiple="multiple" />
并在您的PHP代码中
//Loop through each file
for($i=0; $i<count($_FILES['upload']['name']); $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
//Handle other code here
}
}
}
希望这有帮助。