AJAX file upload/form submit without jquery or iframes?

前端 未结 3 1169
野趣味
野趣味 2020-12-31 19:39

Is it possible to do an AJAX form submit without jQuery or IFrames (so just pure JavaScript)? I\'m currently sending to a struts fileUploadAction that works. Would the actio

3条回答
  •  一整个雨季
    2020-12-31 20:18

    No need to add jquery or any other third party library, just add IPerfect JS library and you are good to go.

    IP_uploadFile(URL,responseType,this[object],[dynamicFunctionForResponse])

    if user select responseType as 'html' then dynamicFunctionForResponse will get response in HTML format. In below example you will get 'done' response in alert.

    HTML

        
    
    
        
    

    Body

        

    PHP: testupload.php

        move_uploaded_file($_FILES['file1']['tmp_name'], realpath("./")."/upload/".$_FILES["file1"]["name"]);
        echo "done";
    

提交回复
热议问题