0

I am missing one thing. When I get this email in my inbox it doesn't have the image that was uploaded. It literally says :

Status: Student First: John Last: Doe Middle: None Where: New York,NY Grad: 2014 Gender: male Image: Array

I need to know how to get the image and not the word "array". Please do not recommend PHPmailer or any other option. I would like help with this coding and only this coding. Thank you.

<?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'];
$file = $_FILES['file'];
$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 \r\n Image:$file";
$recipient = "example@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>";
?>
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;
}
<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">
 <h1>Registration</h1>
  <form action="assets/php/mail.php" method="post" enctype="multipart/form-data">
<hr>
<div class="accounttype">
 <input type="radio" value="student" id="student" name="accounttype" checked/>
 <label for="student" class="radio" chec>Student</label>
 <input type="radio" value="faculty" id="faculty" name="accounttype" />
 <label for="faculty" class="radio">Faculty</label>
</div>
<hr>
 <label id="icon" for="name"><i class="icon-user "></i></label>
 <input type="text" name="firstname" id="firstname" placeholder="First Name" required/>
 <label id="icon" for="name"><i class="icon-user"></i></label>
 <input type="text" name="lastname" id="lastname" placeholder="Last Name" required/>
 <label id="icon" for="name"><i class="icon-shield"></i></label>
 <input type="text" name="middlename" id="middlename" placeholder="Middle Name"/>
<hr>
 <label id="icon" for="name"><i class="icon-envelope "></i></label>
 <input type="email" name="email" id="email" placeholder="Email Address" required/>
 <label id="icon" for="name"><i class="icon-map-marker "></i></label>
 <input type="text" name="location" id="location" placeholder="City, State" required/>
 <label id="icon" for="name"><i class="icon-shield"></i></label>
 <input type="number" name="year" id="year" placeholder="Graduation Year" required/>
<hr>
<div class="gender">
 <input type="radio" value="male" id="male" name="gender" checked/>
 <label for="male" class="radio" chec>Male</label>
 <input type="radio" value="female" id="female" name="gender" />
 <label for="female" class="radio">Female</label>
<hr>
 <p>Upload full body image</p>
    <input type="file" accept="image/*;capture=camera" name="file">
</div> 
<p>By clicking Register, you agree on our <a href="#">terms and condition</a>.</p>
 <input type="submit" class="button" value="Send" />
</form>
</div>
</body>
John
  • 29
  • 4
  • 1
    Yes, [$_FILES](http://php.net/manual/en/features.file-upload.post-method.php) is an array. Also you couldn't just throw it into a text mail and hope that it transfers. – mario Sep 27 '15 at 05:59
  • when you `var_dump($files);` What is the output? – aldrin27 Sep 27 '15 at 05:59
  • Don't use the `mail()` function for this task, [Send attachments with PHP Mail()?](http://stackoverflow.com/q/12301358). (There are hundreds of duplicates without PHPMailer, if you looked for them. Be forewarned that this manual MIME construction garbage code rarely works for long.) – mario Sep 27 '15 at 06:04
  • check this too http://stackoverflow.com/questions/17231030/how-to-insert-an-image-in-php-mail – aimme Sep 27 '15 at 06:06
  • You are sending the e-mail based on a post and discarding the data afterwards? – Julio Soares Sep 27 '15 at 06:12
  • You have added $file = $_FILES['file']; directly into your email template . Whereas $_FILES['file'] is itself an array http://php.net/manual/en/reserved.variables.files.php .So upload file to particular location and then give path of that location into your email template – Exception Sep 27 '15 at 06:17
  • @mario you linked me to an answer that relates to PHPmailer when I specifically stated that I do not use PHPmailer. Thanks for the attention to detail. – John Sep 27 '15 at 06:33
  • @aldrin27 I literally do not know what that means or how to do that. If you could tell me i'll do it and tell you what the results are. – John Sep 27 '15 at 06:34
  • @JulioSoares yeah I'm not storing the images anywhere. I'd like to keep them in my email. – John Sep 27 '15 at 06:37
  • @Exception not sure what that means. I just want to know if there is a way to get images straight to my email. Not on my server or into a folder. Just straight into my email. – John Sep 27 '15 at 06:38
  • @John that is not possible because the file you have uploaded is now stored on `tmp` location of your PC/server (in non-readable format). So you have to get that image from that location and upload it to somewhere else (it will be in readable format now) and then you can give path of that image into your template.thats it.. – Exception Sep 27 '15 at 06:42
  • @Exception Thank you, Thank you, Thank you, It took 3 days for someone to give me a legitimate answer. Thank you, I will remove the image upload option from my form. THANK YOU – John Sep 27 '15 at 06:48
  • @john completely my pleasure – Exception Sep 27 '15 at 06:51

0 Answers0