| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4609 人关注过本帖
标题:求ajaxfileupload.js上传文件的解决方案
只看楼主 加入收藏
yaopeng0418
Rank: 1
等 级:新手上路
帖 子:79
专家分:0
注 册:2008-12-28
结帖率:70.83%
收藏
 问题点数:0 回复次数:0 
求ajaxfileupload.js上传文件的解决方案
$.ajaxFileUpload(  
                {
                   url:'upld5.asp',            //需要链接到服务器地址  
                   secureuri:false,
                   fileElementId:'upfile',
                   dataType:'json',
                   success:function(data,status)
                   {alert(eval('('+data.conn+')'));
                  
                   },
                   error:function(data,status,e)
                   { alert(eval('(' + data.conn + ')'));
                  // var text=split(unescape(data),"/")(0);
                   $.each(data,function(i,n){
                                    //    $("#cont").append("<span>"+ text +"</span>");
//                                        $("#win").show();
                                        });
                   }
                   }
                   );
upld5.asp代码如下:
ExtName = "jpg,gif,png" '允许扩展名
SavePath ="./folder"'保存路径
If Right(SavePath,1)<>"/" Then SavePath=SavePath&"/" '在目录后加(/)
CheckAndCreateFolder(SavePath)

UpLoadAll_a = Request.TotalBytes '取得客户端全部内容
If(UpLoadAll_a>0) Then
Set UploadStream_c = Server.CreateObject("ADODB.Stream")
UploadStream_c.Type = 1
UploadStream_c.Open
UploadStream_c.Write Request.BinaryRead(UpLoadAll_a)
UploadStream_c.Position = 0

FormDataAll_d = UploadStream_c.Read
CrLf_e = chrB(13)&chrB(10)
FormStart_f = InStrB(FormDataAll_d,CrLf_e)
FormEnd_g = InStrB(FormStart_f+1,FormDataAll_d,CrLf_e)

Set FormStream_h = Server.Createobject("ADODB.Stream")
FormStream_h.Type = 1
FormStream_h.Open
UploadStream_c.Position = FormStart_f + 1
UploadStream_c.CopyTo FormStream_h,FormEnd_g-FormStart_f-3
FormStream_h.Position = 0
FormStream_h.Type = 2
FormStream_h.CharSet = "GB2312"
FormStreamText_i = FormStream_h.Readtext
FormStream_h.Close
FileName_j = Mid(FormStreamText_i,InstrRev(FormStreamText_i,"\")+1,FormEnd_g)
If(CheckFileExt(FileName_j,ExtName)) Then
SaveFile = Server.MapPath(SavePath & FileName_j)
If Err Then
Response.Write ([{"conn":"文件上传出错!"}])
Err.Clear
Else
SaveFile = CheckFileExists(SaveFile)
k=Instrb(FormDataAll_d,CrLf_e&CrLf_e)+4
l=Instrb(k+1,FormDataAll_d,leftB(FormDataAll_d,FormStart_f-1))-k-2
FormStream_h.Type=1
FormStream_h.Open
UploadStream_c.Position=k-1
UploadStream_c.CopyTo FormStream_h,l
FormStream_h.SaveToFile SaveFile,2

SaveFileName = Mid(SaveFile,InstrRev(SaveFile,"\")+1)
Response.write ([{"conn":"文件上传成功!"&"/"&SaveFileName}])
End If
Else
Response.write ([{"conn":"文件格式不正确!"}])
End If 怎么上传没反应,

搜索更多相关主题的帖子: 解决方案 服务器 function success 上传文件 
2012-05-21 07:43
快速回复:求ajaxfileupload.js上传文件的解决方案
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039033 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved