0

Can one help me how i can upload files with JQuery, am using JQuery to submit form where a user is allowed to enter some data in the text-area and also attach image file to the note so i have a problem that the form is not able to upload the file but only the text and timestamp of the uploaded image. is there anyone know how i can do this

JQuery

$(document).ready(function() {
     $("#statusForm").submit(function() {
     var frm = $('#statusForm');
        $.ajax({
            type: frm.attr('method'),
            url: 'tweet.php',
            data: frm.serialize(),
            success: function (data) {
            $('#new_tweet').html(data);
            $('#txtArea').val('');
            },
            error: function(jqXHR, textStatus, errorThrown){
            // log the error to the console
            console.log(
                "The following error occured: "+
                textStatus, errorThrown
            );
            }

        });

        return false;
    });
});

HTML

<form action="tweet.php" method="post" id="statusForm" name="statusForm" enctype="multipart/form-data">
<textarea id="txtArea"  name="status"  placeHolder="whatsup today" class="txtArea" onfocus="this.rows=7;"></textarea>
<input type="button" id="photo" value="+Image" class="buttons"> 
<input type="hidden" id="checkin">
<input type="submit" value="submit" class="Mbuttons" id="sub" name="submit">
</form>

I ll also appreciate any suggestion

BenMorel
  • 31,815
  • 47
  • 169
  • 296
codefun
  • 13
  • 1
  • 2
  • 6
  • possible duplicate of [How can I upload files asynchronously with jQuery?](http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery) – Tamillharasan Jun 26 '13 at 05:14
  • This question is answered already [here](http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery). Lots of good answers, it might be useful for you to go through all them. – Tamillharasan Jun 26 '13 at 05:11
  • possible duplicate of [Jquery ajax fileupload via php](http://stackoverflow.com/questions/13306447/jquery-ajax-fileupload-via-php) – Paul Sweatte Dec 27 '14 at 18:45

0 Answers0