forms - PHP - upload files [POST] -


i have e-mail form here in php. text, ale other fields works fine. problem uploading file. looks me. function file e-mails sended. there isn`t attachement in message. when click "wyślij wiadomość" (send) have message problem uploading file. enyone know goes wrong?

<?php  //--- początek formularza ---  if(empty($_post['submit'])) {  ?>    		    <form action="" method="post">                          <table class="col-md-10 col-sm-12 col-xs-12">                              <tr>                                  <td class="col-md-2">nazwisko:<br /><br/></td>                                  <td><input type="text" name="formname" /></td>                              </tr>  			<tr>                              <td class="col-md-2">e-mail:<br /><br/></td>                              <td><input type="text" name="formemail"/></td>                          </tr>                          <tr>                              <td class="col-md-2">zaŁĄcz kosztorys:<br /><br/></td>                              <td><input type="file" name="formfile" /></td>                          </tr>                          <tr>                              <td class="formularztresc col-md-2">treŚĆ:<br /><br/></td>                              <td><textarea name="formtext"></textarea></td>                          </tr>                          <tr>                              <td></td>                              <td><p align="right"><input type="submit" name="submit" value="wyślij wiadomość" /><p></td>                          </tr>                          </table>                      </form>  <?php  } else {    //dane adresata  $email = '#';    //dane z formularza  $formname = $_post['formname'];  $formemail = $_post['formemail'];  $formtext = $_post['formtext'];  $formfile = $_post['formfile'];    if(!empty($formname) && !empty($formemail) && !empty($formtext)) {    //--- początek funkcji weryfikującej adres e-mail ---  function checkmail($checkmail) {    if(filter_var($checkmail, filter_validate_email)) {      if(checkdnsrr(array_pop(explode("@",$checkmail)),"mx")){          return true;        }else{          return false;        }    } else {      return false;    }  }  //--- koniec funkcji ---  if(checkmail($formemail)) {    //dodatkowe informacje: ip host użytkownika    $ip = $_server['remote_addr'];    $host = gethostbyaddr($_server['remote_addr']);       //tworzymy szkielet wiadomości    //treść wiadomości    $mailtext = "treść wiadomości:\n$formtext\nod: $formname, $formemail, $formfile ($ip, $host)";       //adres zwrotny    $mailheader = "from: $formname <$formemail>\r\n";  	$mailheader .= "content-type: text/plain; charset=utf-8\r\n";            $target_path = "../przeslanepliki";          $target_path = $target_path . basename( $_files['formfile']['name']);  if(move_uploaded_file($_files['formfile']['tmp_name'], $target_path)) {      echo "the file ".  basename( $_files['formfile']['name']).       "plik został wysłany";            } else{      echo "wystąpił problem z przesłaniem pliku. prosimy spróbować ponownie.";  }  	    //funkcja odpowiedzialna za wysłanie e-maila    @mail($email, 'pytanie eksperta', $mailtext, $mailheader) or die('błąd: wiadomość nie została wysłana');       //komunikat o poprawnym wysłaniu wiadomości    echo 'wiadomość została wysłana';  } else {    echo 'adres e-mail jest niepoprawny';  }    } else {    //komunikat w przypadku nie powodzenia    echo 'wypełnij wszystkie pola formularza';  }    //--- koniec formularza ---  }  ?>

the form needs following attribute: enctype="multipart/form-data". specifies content-type use when submitting form

<form action="" method="post" enctype="multipart/form-data"> 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -