Ronnielee's avatar

How use AJAX upload file asynchronous ?

I want to upload file to server asynchronous.

js

  $('#uploadfile').fileupload({
          url:'../uploadfile',
          dataType: 'json',
          done: function (e, data) {

            $.each(data.files, function (index, file) {
                // $('<li/>').text("finished").appendTo('#divfile');
                var phtml="<p>finished</p>"
                $('#divfile').append(phtml);
            });
           $('#uploadfprogress').fadeOut();
           // $('#uploadbt').prop('disabled', true);
          },
          progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10) + '%';
           $('#uploadbar1').css('width', progress);
           $('#uploadbar1').text(progress);
          },
          fail: function (e, data) {
            alert(data.errorThrown);
          }
    });

view:

route:

Route::post('uploadfile',function() {
print_r(Input::file('uploadfile')); });

have anybody know how to continue?

thanks avant

0 likes
1 reply
Ronnielee's avatar
                                        <input type="text" name="inputfname" class="form-control" id="inputfname" />
                                        <div class="input-group-btn">
                                            <input type="button" id="uploadbt" class="btn btn-success fileinput-button" onclick="$('#uploadfile').click();"  value="select"/> 
                                        </div>                                          
                                        <input id="uploadfile" type="file" name="uploadfile" style="display:none" multiple />

Please or to participate in this conversation.