Javascript code: {code...} background code: {code...} the returned data is [] javascript code:
Script var up = function (o, success, x, file) {if (typeof success = 'function') file = o; x = new XMLHttpRequest () x. open ('post', 'http: // 127.0.0.1/up. php? R = '+ Math. random (), 1) x. onload = function (r) {r = x. responseText if (success) // if r. pid and the twice parameter existing return success (r)} x. send (file)} script, script, img. onchange = function () {if (! This. files |! This. files [0]) return alert ('an error occurred while selecting the file! ') Var imgfile = this. files [0] if (imgfile. type. indexOf ('image ')! = 0) return alert ('this is not an image or audio! ') Up (imgfile, function (r) {text. innerHTML = r})} script
Background code:
The returned data is []
Reply content:
Javascript code:
Script var up = function (o, success, x, file) {if (typeof success = 'function') file = o; x = new XMLHttpRequest () x. open ('post', 'http: // 127.0.0.1/up. php? R = '+ Math. random (), 1) x. onload = function (r) {r = x. responseText if (success) // if r. pid and the twice parameter existing return success (r)} x. send (file)} script, script, img. onchange = function () {if (! This. files |! This. files [0]) return alert ('an error occurred while selecting the file! ') Var imgfile = this. files [0] if (imgfile. type. indexOf ('image ')! = 0) return alert ('this is not an image or audio! ') Up (imgfile, function (r) {text. innerHTML = r})} script
Background code:
The returned data is []
Upload files asynchronously. useFormData
. For example:
var oMyForm = new FormData();oMyForm.append("file", file);x.send(oMyForm);
Reference: http://www.cnblogs.com/lhb25...