jQuery AJAX file upload PHP

前端 未结 6 845
小鲜肉
小鲜肉 2020-11-21 05:15

I want to implement a simple file upload in my intranet-page, with the smallest setup possible.

This is my HTML part:



        
6条回答
  •  北恋
    北恋 (楼主)
    2020-11-21 06:03

    var formData = new FormData($("#YOUR_FORM_ID")[0]);
    $.ajax({
        url: "upload.php",
        type: "POST",
        data : formData,
        processData: false,
        contentType: false,
        beforeSend: function() {
    
        },
        success: function(data){
    
    
    
    
        },
        error: function(xhr, ajaxOptions, thrownError) {
           console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
    });
    

提交回复
热议问题