从html表单通过php获取图像到电子邮件

时间:2015-09-25 00:47:44

标签: php html

我对此表单有疑问。它通过电子邮件发送给我收集的所有数据,但我没有得到任何图像。对于我们中间的天才,我没有写任何PHP来尝试获取,因为我不知道使用哪种编码。非常感谢任何帮助。谢谢



empty, and Exit Sub

<?php
$accounttype = $_POST['accounttype'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$middlename = $_POST['middlename'];
$email = $_POST['email'];
$location = $_POST['location'];
$year = $_POST['year'];
$gender = $_POST['gender'];
$formcontent = "Status: $accounttype \r\n  First: $firstname \r\n  Last:$lastname \r\n Middle:$middlename \r\n Where:$location \r\n Grad:$year \r\n Gender:$gender";
$recipient = "john.doe@gmail.com";
$subject = "Registration Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='../../index.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>
&#13;
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td { 
  	padding:0;
  	margin:0;
}

fieldset, img {
	border: 0;
}

ol, ul, li {
	list-style: none;
}

:focus {
	outline: none;
}

body, input, textarea, select {
  	font-family: 'Open Sans', sans-serif;
  	font-size: 16px;
  	color: #4c4c4c;
}

p {
  	font-size: 12px;
  	width: 150px;
  	display: inline-block;
  	margin-left: 18px;
}

h1 {
  font-size: 32px;
  font-weight: 300;
  color: #4c4c4c;
  text-align: center;
  padding-top: 10px;
  margin-bottom: 10px;
}

html{
  background-color: #ffffff;
}

.testbox {
  margin: 20px auto;
  width: 343px; 
  -webkit-border-radius: 8px/7px; 
  -moz-border-radius: 8px/7px; 
  border-radius: 8px/7px; 
  background-color: #ebebeb; 
  -webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.31); 
  -moz-box-shadow: 1px 2px 5px rgba(0,0,0,.31); 
  box-shadow: 1px 2px 5px rgba(0,0,0,.31); 
  border: solid 1px #cbc9c9;
}

input[type=radio] {
  visibility: hidden;
}

form {
	height:auto;
  	margin: 0 30px;
}

label.radio {
	cursor: pointer;
  	text-indent: 35px;
  	overflow: visible;
  	display: inline-block;
  	position: relative;
  	margin-bottom: 15px;
}

label.radio:before {
  	background: #3a57af;
  	content:'';
  	position: absolute;
  	top:2px;
  	left: 0;
  	width: 20px;
  	height: 20px;
  	border-radius: 100%;
}

label.radio:after {
	opacity: 0;
	content: '';
	position: absolute;
	width: 0.5em;
	height: 0.25em;
	background: transparent;
	top: 7.5px;
	left: 4.5px;
	border: 3px solid #ffffff;
	border-top: none;
	border-right: none;
	-webkit-transform: rotate(-45deg);
	-moz-transform: rotate(-45deg);
	-o-transform: rotate(-45deg);
	-ms-transform: rotate(-45deg);
	transform: rotate(-45deg);
}

input[type=radio]:checked + label:after {
	opacity: 1;
}

hr {
  	color: #a9a9a9;
  	opacity: 0.3;
}

input[type=text],input[type=email],input[type=number] {
  	width: 200px; 
  	height: 39px; 
  	-webkit-border-radius: 0px 4px 4px 0px/5px 5px 4px 4px; 
  	-moz-border-radius: 0px 4px 4px 0px/0px 0px 4px 4px; 
  	border-radius: 0px 4px 4px 0px/5px 5px 4px 4px; 
  	background-color: #fff; 
  	-webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.09); 
  	-moz-box-shadow: 1px 2px 5px rgba(0,0,0,.09); 
  	box-shadow: 1px 2px 5px rgba(0,0,0,.09); 
  	border: solid 1px #cbc9c9;
  	margin-left: -5px;
  	margin-top: 13px; 
  	padding-left: 10px;
}

input[type=password] {
  	margin-bottom: 25px;
}

#icon {
  	display: inline-block;
  	width: 30px;
  	background-color: #3a57af;
  	padding: 8px 0px 8px 15px;
  	margin-left: 15px;
  	-webkit-border-radius: 4px 0px 0px 4px; 
  	-moz-border-radius: 4px 0px 0px 4px; 
  	border-radius: 4px 0px 0px 4px;
  	color: white;
  	-webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
  	-moz-box-shadow: 1px 2px 5px rgba(0,0,0,.09); 
  	box-shadow: 1px 2px 5px rgba(0,0,0,.09); 
  	border: solid 0px #cbc9c9;
}

.gender {
  	margin-left: 30px;
  	margin-bottom: 30px;
}

.accounttype {
  	margin-left: 8px;
  	margin-top: 20px;
}

.button {
  	font-size: 14px;
  	font-weight: 600;
  	color: white;
  	padding: 6px 25px 0px 20px;
  	margin: 10px 8px 20px 0px;
  	display: inline-block;
  	float: right;
  	text-decoration: none;
  	width: auto; height: 27px; 
  	-webkit-border-radius: 5px; 
  	-moz-border-radius: 5px; 
  	border-radius: 5px; 
  	background-color: #3a57af; 
  	-webkit-box-shadow: 0 3px rgba(58,87,175,.75); 
  	-moz-box-shadow: 0 3px rgba(58,87,175,.75); 
  	box-shadow: 0 3px rgba(58,87,175,.75);
  	transition: all 0.1s linear 0s; 
  	top: 0px;
  	position: relative;
}

.button:hover {
  	top: 3px;
  	background-color:#2e458b;
  	-webkit-box-shadow: none; 
  	-moz-box-shadow: none; 
  	box-shadow: none;
}
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

这是因为您没有上传图像因此发送文件的位置没有帮助。

我不打算提供实现,因为它取决于您选择的抽象解决方案: a)将图像上传到服务器并将图像发送给您 b)将图像上传到文件共享网站并将图像发送给您

答案 1 :(得分:0)

首先,您需要将图像上传到服务器,然后创建链接http://abcd.com/directory/uploaded-image.jpg并通过电子邮件发送。为此你可以使用非常简单的php函数

  

move_uploaded_files

参见示例here