Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. <form enctype="multipart/form-data" method="post" id="contact-form-block-1">
  2. <div>
  3. <div class="icon">
  4. <input class="form-control contact-name" type="text" name="contact_name" required="" placeholder="Имя">
  5. </div>
  6. <div class="des">
  7. <input class="form-control contact-file" type="file" name="contact_file">
  8. </div>
  9. <input type="submit" value="Отправить заявку">
  10. </div>
  11. </form>
  12.  
  13. jQuery(function($){
  14. $('form').each(function (index) {
  15. $(this).attr('id', 'gfort-contact-form-block-' + index);
  16. $('#gfort-contact-form-block-' + index).submit(function () {
  17. var el = $(this),
  18. formValues = new FormData(el);
  19. $.ajax({
  20. url: 'http://<?=$_SERVER["HTTP_HOST"]?>/include/contact.php',
  21. data: formValues,
  22. processData: false,
  23. contentType: false,
  24. type: 'POST',
  25. success: function (response) {
  26.  
  27. }
  28. });
  29. */
  30. return false;
  31. });
  32. return false;
  33. });
  34. });
  35.  
  36. if(isset($_POST)){
  37. $email_address = "<........>";
  38.  
  39. if(isset($_FILES['contact_file'])){
  40. $uploaddir = '<........>';
  41. $uploadfile = $uploaddir . basename($_FILES['contact_file']['name']);
  42. if (move_uploaded_file($_FILES['contact_file']['tmp_name'], $uploadfile)) {
  43. $contact_file = 'Файл: <a href="http://'.$_SERVER["HTTP_HOST"].'/userfiles/'.basename($_FILES['contact_file']['name']).'">скачать</a><br>';
  44. } else {
  45. echo '<div class="error-file">Ошибка отправки файла.</div>';
  46. return false;
  47. }
  48. }
  49. }
  50. $send_subject = "123";
  51. $send_message = $contact_file;
  52. $headers = "<........>";
  53.  
  54. if (mail($email_address, $send_subject, $contact_file, $headers)) { */
  55. echo '<div class="success-message">удачно</div>';
  56. return false;
  57. } else {
  58. echo 'Ошибка';
  59. return false;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement