客户端jsLinb类:- Class('App', 'linb.Com',{
- Instance:{
- iniComponents:function(){
- // [[code created by jsLinb UI Builder
- var host=this, children=[], append=function(child){children.push(child.get(0))};
-
- append((new linb.UI.SLabel)
- .host(host,"slabel1")
- .setLeft(40)
- .setTop(44)
- .setCaption("Select your file: ")
- );
-
- append((new linb.UI.ComboInput)
- .host(host,"upload")
- .setLeft(140)
- .setTop(40)
- .setWidth(140)
- .setReadonly(true)
- .setType("upload")
- .setValue("Select a file ...")
- );
-
- append((new linb.UI.SButton)
- .host(host,"sbutton3")
- .setLeft(290)
- .setTop(40)
- .setCaption("Upload it")
- .onClick("_sbutton3_onclick")
- );
-
- return children;
- // ]]code created by jsLinb UI Builder
- },
- _sbutton3_onclick:function (profile, e, src, value) {
- var file=this.upload.getUploadObj();
- if(file){
- // 请求服务的地址是request.php
- linb.request('request.php',{file:file},function(rsp){
- linb.alert(rsp.data.message);
- },function(errMsg){
- linb.alert(errMsg)
- }).start();
- }
- }
- }
- });
复制代码 服务端request.php 的内容:- <?php
- move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
- echo "<script>window.name=\"{id:'".$_POST["id"]."',data:{message:'ok'}}\"</script>"
- ?>
复制代码 |