No need to add jquery or any other third-party library, just add the IPerfect JS library and you're good to go.
IP_uploadFile (URL, responseType, this is [object], [dynamicFunctionForResponse])
if the user selects responseType as 'html', then dynamicFunctionForResponse will receive an HTML response. In the example below, you will get the answer "done" in the warning.
HTML
<script type="text/javascript" src="http://services.iperfect.net/js/IP_generalLib.js"></script> <script language='javascript'> function testResponse(data){ alert(data) } </script>
Body
<form method="POST" enctype="multipart/form-data" onsubmit="IP_uploadFile('testupload.php','html',this,testResponse); return false;"> <input type="file" name="file1"> <input type="submit" name="submit1" value="Click here"> </form>
PHP: testupload.php
move_uploaded_file($_FILES['file1']['tmp_name'], realpath("./")."/upload/".$_FILES["file1"]["name"]); echo "done";
source share