//代码
//---------------------------------------------------
import flash.net.FileReference; //引入类
bt1.label="上传"
label1.text=""
var file:FileReference = new FileReference();
var ob:Object = new Object();
ob.onSelect = function (file:FileReference):Void{
file.upload("http://www.faithmedia.com.cn/UploadFile/upfile.asp");
}
ob.onProgress=function(f,l,t){
label1.text="上传中....."
p.setProgress(l,t)
if((l/t)*100==100){
label1.text="上传完成"
bt1.label="上传"
file.cancel()
}
}
ob.onCancel = function (fresele:FileReference):Void{
label1.text="取消上传"
bt1.label="上传"
file.cancel()
}
ob.onComplete=function(f){
label1.text="上传完成"
bt1.label="上传"
}
bt1.onPress = function() {
if (bt1.label=="上传"){
bt1.label="取消"
label1.text="正在上传"
file.browse();
}
else{
bt1.label="上传"
label1.text="取消上传"
file.cancel()
}
}
file.addListener(ob);
//---------------------------------------------------
ASP接收FLASH上传来的二进制流数据,生成图片,进行估存
<%Dim biData, PostData, TotalBytes, ChunkBytes
ChunkBytes = 1 * 1024 ' 分块大小为1K
TotalBytes = Request.TotalBytes ' 总大小
PostData = "" ' 转化为文本类型后的数据
ReadedBytes = 0 ' 初始化为0
' 分块读取
Set bSourceData = createobject("ADODB.Stream")
bSourceData.Open
bSourceData.Type = 1 'Binary
Do While ReadedBytes < TotalBytes
biData = Request.BinaryRead(ChunkBytes)
bSourceData.Write biData ' 直接使用write方法将当前文件流写入bSourceData中
ReadedBytes = ReadedBytes + ChunkBytes
If ReadedBytes > TotalBytes Then ReadedBytes = TotalBytes
Application("ReadedBytes") = ReadedBytes
Loop
ranNum=int(90000*rnd)+10000
FileName=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&".gif"
path=GetFilePath(Server.mappath("upfile.asp"),"\")&"upload\"
fullpath=path&filename
bSourceData.SaveToFile fullpath,2
%>
<!--#include virtual="/inc/conn_f.asp"-->
<%
dim conn,rs
call conn_open
sql="select * from casio2_items"
rs.open sql,conn,3,3
rs.AddNew
rs("title")=request("title")
rs("content")=request("info")
'rs("pic")=filename
rs.update
rs.close
set rs=nothing
%>
<%
function GetFilePath(FullPath,str)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, str))
Else
GetFilePath = ""
End If
End function
%>