-2

I have this form designed and have no idea how to hook it up with php to send the data by email. The upload file must be jpeg and size no more than 30kb. Can you help me please?

For newbee like me it is big challenge. Yet, its a piece of cake for pros like you.

<!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>

1 Answers1

0

Here it goes :

Make your HTML as :

<input name="upload[]" type="file" multiple="multiple" />

and in your php code

//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

    }
  }
}

Hope this helps.

Drudge Rajen
  • 5,431
  • 4
  • 19
  • 41