0

I have simple sendemail.php form. I want add file sending (file will be added to ftp). This is my form:

<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php" enctype="multipart/form-data">
    <input type="text" placeholder="Vardas Pavarde" name="vp" id="contact-form-name" value="" style="color: #9F9F9F; font: 13px Arial; float: left; width: 180px; border: none; background: none; border: solid 1px #343434;"/><br/>
    <textarea name="zinute" rows="3" cols="40" style="color: #9F9F9F; font: 13px Arial; float: left; width: 180px; border: none; background: none; border: solid 1px #343434;"></textarea><br/>
    <input type="file" id="foto" required="required" name="foto" style="color: #9F9F9F; font: 13px Arial; float: left; width: 180px; border: none; background: none; border: solid 1px #343434;"><br/>
    <input type="submit" class="button" id="contact-form-send" value="Siusti" style="color: #9F9F9F; font: 13px Arial; float: left; width: 180px; border: none; background: none; border: solid 1px #343434;" />
</form>

This is my sendemail.php:

<?php
    header('Content-type: application/json');
    $status = array(
        'type'=>'success',
        'message'=>'Thank you for contact us. As early as possible  we will contact you '
    );
    $vp = @trim(stripslashes($_POST['vp'])); 
    $zinute = @trim(stripslashes($_POST['zinute'])); 

    move_uploaded_file($_FILES['foto']['tmp_name'], 'image/' . $_FILES['foto']['name']);

    $success = @seet($vp, zinte);

    echo json_encode($status);
    die;

I thinking problem is in the jQuery AJAX code but I haven't studied this language so please help. Thanks all!

jQuery:

var form = $('#main-contact-form');
form.submit(function(event){
    event.preventDefault();
    var form_status = $('<div class="form_status"></div>');
    $.ajax({
        url: $(this).attr('action'),
        beforeSend: function(){
            form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
        }
    }).done(function(data){
        form_status.html('<p class="text-success">' + data.message + '</p>').delay(3000).fadeOut();
    });
});
Sam
  • 7,252
  • 16
  • 46
  • 65
Imona Mil
  • 11
  • 1

0 Answers0