xui.Class('App', 'xui.Com',{ Instance:{ iniComponents:function(){ // [[Code created by CrossUI RAD Tools var host=this, children=[], append=function(child){children.push(child.get(0))}; append( (new xui.UI.SLabel) .setHost(host,"slabel1") .setLeft(30) .setTop(44) .setCaption("Select your file: ") ); append( (new xui.UI.SButton) .setHost(host,"sbutton3") .setLeft(320) .setTop(40) .setCaption("Upload it") .onClick("_sbutton3_onclick") ); append( (new xui.UI.ComboInput) .setHost(host,"upload") .setReadonly(true) .setLeft(130) .setTop(40) .setWidth(180) .setType("file") .setValue("Select a file ...") ); return children; // ]]Code created by CrossUI RAD Tools }, _sbutton3_onclick:function (profile, e, src, value) { var file=this.upload.getUploadObj(); if(file){ xui.request('request.php',{file:file},function(rsp){ xui.alert(rsp.data.message); },function(errMsg){ xui.alert(errMsg) }).start(); } } } });
php code
<?php move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "<script>window.name=\"{id:'".$_POST["id"]."',data:{message:'ok'}}\"</script>" ?>