У меня возникла проблема с этой формой. Он отправляет мне все данные, которые он собирает, но я не получаю никаких изображений. К гениальности среди нас я не писал никаких php, чтобы попытаться получить, потому что я не знаю, какое кодирование использовать. Любая помощь глубоко ценится. СпасибоПолучение изображения из html-формы через php по электронной почте
<?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 = "[email protected]";
$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>";
?>
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td {
\t padding:0;
\t margin:0;
}
fieldset, img {
\t border: 0;
}
ol, ul, li {
\t list-style: none;
}
:focus {
\t outline: none;
}
body, input, textarea, select {
\t font-family: 'Open Sans', sans-serif;
\t font-size: 16px;
\t color: #4c4c4c;
}
p {
\t font-size: 12px;
\t width: 150px;
\t display: inline-block;
\t 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 {
\t height:auto;
\t margin: 0 30px;
}
label.radio {
\t cursor: pointer;
\t text-indent: 35px;
\t overflow: visible;
\t display: inline-block;
\t position: relative;
\t margin-bottom: 15px;
}
label.radio:before {
\t background: #3a57af;
\t content:'';
\t position: absolute;
\t top:2px;
\t left: 0;
\t width: 20px;
\t height: 20px;
\t border-radius: 100%;
}
label.radio:after {
\t opacity: 0;
\t content: '';
\t position: absolute;
\t width: 0.5em;
\t height: 0.25em;
\t background: transparent;
\t top: 7.5px;
\t left: 4.5px;
\t border: 3px solid #ffffff;
\t border-top: none;
\t border-right: none;
\t -webkit-transform: rotate(-45deg);
\t -moz-transform: rotate(-45deg);
\t -o-transform: rotate(-45deg);
\t -ms-transform: rotate(-45deg);
\t transform: rotate(-45deg);
}
input[type=radio]:checked + label:after {
\t opacity: 1;
}
hr {
\t color: #a9a9a9;
\t opacity: 0.3;
}
input[type=text],input[type=email],input[type=number] {
\t width: 200px;
\t height: 39px;
\t -webkit-border-radius: 0px 4px 4px 0px/5px 5px 4px 4px;
\t -moz-border-radius: 0px 4px 4px 0px/0px 0px 4px 4px;
\t border-radius: 0px 4px 4px 0px/5px 5px 4px 4px;
\t background-color: #fff;
\t -webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
\t -moz-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
\t box-shadow: 1px 2px 5px rgba(0,0,0,.09);
\t border: solid 1px #cbc9c9;
\t margin-left: -5px;
\t margin-top: 13px;
\t padding-left: 10px;
}
input[type=password] {
\t margin-bottom: 25px;
}
#icon {
\t display: inline-block;
\t width: 30px;
\t background-color: #3a57af;
\t padding: 8px 0px 8px 15px;
\t margin-left: 15px;
\t -webkit-border-radius: 4px 0px 0px 4px;
\t -moz-border-radius: 4px 0px 0px 4px;
\t border-radius: 4px 0px 0px 4px;
\t color: white;
\t -webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
\t -moz-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
\t box-shadow: 1px 2px 5px rgba(0,0,0,.09);
\t border: solid 0px #cbc9c9;
}
.gender {
\t margin-left: 30px;
\t margin-bottom: 30px;
}
.accounttype {
\t margin-left: 8px;
\t margin-top: 20px;
}
.button {
\t font-size: 14px;
\t font-weight: 600;
\t color: white;
\t padding: 6px 25px 0px 20px;
\t margin: 10px 8px 20px 0px;
\t display: inline-block;
\t float: right;
\t text-decoration: none;
\t width: auto; height: 27px;
\t -webkit-border-radius: 5px;
\t -moz-border-radius: 5px;
\t border-radius: 5px;
\t background-color: #3a57af;
\t -webkit-box-shadow: 0 3px rgba(58,87,175,.75);
\t -moz-box-shadow: 0 3px rgba(58,87,175,.75);
\t box-shadow: 0 3px rgba(58,87,175,.75);
\t transition: all 0.1s linear 0s;
\t top: 0px;
\t position: relative;
}
.button:hover {
\t top: 3px;
\t background-color:#2e458b;
\t -webkit-box-shadow: none;
\t -moz-box-shadow: none;
\t box-shadow: none;
}
<html>
<body>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600' rel='stylesheet' type='text/css'>
<link href="//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css" rel="stylesheet">
<?php echo $output; ?>
<div class="testbox">
\t <h1>Registration</h1>
\t \t <form action="assets/php/mail.php" method="post">
<hr>
<div class="accounttype">
\t <input type="radio" value="student" id="student" name="accounttype" checked/>
\t <label for="student" class="radio" chec>Student</label>
\t <input type="radio" value="faculty" id="faculty" name="accounttype" />
\t <label for="faculty" class="radio">Faculty</label>
</div>
<hr>
\t <label id="icon" for="name"><i class="icon-user "></i></label>
\t <input type="text" name="firstname" id="firstname" placeholder="First Name" required/>
\t <label id="icon" for="name"><i class="icon-user"></i></label>
\t <input type="text" name="lastname" id="lastname" placeholder="Last Name" required/>
\t <label id="icon" for="name"><i class="icon-shield"></i></label>
\t <input type="text" name="middlename" id="middlename" placeholder="Middle Name"/>
<hr>
\t <label id="icon" for="name"><i class="icon-envelope "></i></label>
\t <input type="email" name="email" id="email" placeholder="Email Address" required/>
\t <label id="icon" for="name"><i class="icon-map-marker "></i></label>
\t <input type="text" name="location" id="location" placeholder="City, State" required/>
\t <label id="icon" for="name"><i class="icon-shield"></i></label>
\t <input type="number" name="year" id="year" placeholder="Graduation Year" required/>
<hr>
<div class="gender">
\t <input type="radio" value="male" id="male" name="gender" checked/>
\t <label for="male" class="radio" chec>Male</label>
\t <input type="radio" value="female" id="female" name="gender" />
\t <label for="female" class="radio">Female</label>
<hr>
\t <p>Upload full body image</p>
<input type="file" accept="image/*;capture=camera">
</div>
<p>By clicking Register, you agree on our <a href="#">terms and condition</a>.</p>
\t <input type="submit" class="button" value="Send" />
</form>
</div>
</body>
</html>
вы знаете о PHPMailer? – Fiido93
'method =" post "enctype =" multipart/form-data "', если вы планируете отправить изображение на сервер. Вам также необходимо (возможно) проверить ограничения загрузки файлов в файле php.ini. Наконец, в PHP-коде вам понадобятся обработчики, имеющие дело с $ _FILES http://php.net/manual/en/reserved.variables.files.php –
@FiidoFirdauz Я слышал об этом, никогда не использовал его. Я недостаточно осведомлен, чтобы попытаться это сделать. – John