1

I have the following input:

and the following javascript:

function click(){

    var reader = new FileReader();
    var bufferFile;

    var fileName = $('#upload').val();

    reader.onload = function (event) {

        bufferFile = event.target.result;

        var fd = new FormData();
        fd.append('fname', fileName);
        fd.append('bufferFile', bufferFile);
        $.ajax({
            type: 'POST',
            url: 'upload.php',
            data: fd,
            processData: false,
            contentType: false,
            success: function (data) {
                console.log(data);

            };
        });

    };
}

what I actually want is to upload the selected file into a file upload in the server.

The upload.php contains the upload function. When selecting a file, actually nothing happens what is going wrong?

Kevin
  • 41,694
  • 12
  • 53
  • 70
souna
  • 43
  • 3
  • Look this question: [http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery][1] - may be it will be useful for you. [1]: http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery – Simcha Aug 13 '14 at 08:42

0 Answers0