How can I upload a file using jquery's $.ajax function with json and php

后端 未结 8 2326
旧巷少年郎
旧巷少年郎 2020-12-01 23:17

I am trying to upload a file using jQuery\'s $.ajax function but didn\'t get any output. Somebody please help me to solve this. I don\'t know if this script is

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 23:37

    Simply use submit event on form to send the files and prevent default form action

    $('#form').submit(function(e) { return false; });

    and get the file on the server side via

    $_FILES['inputName'];
    

提交回复
热议问题