Flash 8的code,你可以从 C:/Program Files/Macromedia/Flash 8/Samples and Tutorials/Samples/ActionScript/FileUpload 获得
将 selectedFile.upload("http://www.helpexamples.com/flash/file_io/uploadFile.php");改成
selectedFile.upload("upload.aspx");
以下是用C#写的 upload.aspx
<%
@ Page Language
=
"
c#
"
ResponseEncoding
=
"
utf-8
"
%>
<% @ Import Namespace = " System.IO " %>
< script language = " c# " runat = " server " >
string saveToFolder = " images " ;
private void Page_Load( object sender, System.EventArgs e)
... {
HttpFileCollection uploadedFiles = Request.Files;
string Path = Server.MapPath(saveToFolder);
for(int i = 0 ; i < uploadedFiles.Count ; i++)
...{
HttpPostedFile F = uploadedFiles[i];
if(uploadedFiles[i] != null && F.ContentLength > 0)
...{
string newName = F.FileName.Substring(F.FileName.LastIndexOf("/") + 1);
F.SaveAs(Path + "/" + newName);
}
}
}
</ script >
<% @ Import Namespace = " System.IO " %>
< script language = " c# " runat = " server " >
string saveToFolder = " images " ;
private void Page_Load( object sender, System.EventArgs e)
... {
HttpFileCollection uploadedFiles = Request.Files;
string Path = Server.MapPath(saveToFolder);
for(int i = 0 ; i < uploadedFiles.Count ; i++)
...{
HttpPostedFile F = uploadedFiles[i];
if(uploadedFiles[i] != null && F.ContentLength > 0)
...{
string newName = F.FileName.Substring(F.FileName.LastIndexOf("/") + 1);
F.SaveAs(Path + "/" + newName);
}
}
}
</ script >
以下是用VB写的 upload.aspx
<
%@ Page Language
=
"
VB
"
ResponseEncoding
=
"
utf-8
"
%
>
< %@ Import Namespace = Namespace="System.IO" %>
<script language="VB" runat="server">
Dim saveToFolder As String = "images"
Protected Sub Page_Load()Sub Page_Load(Src As object, E As EventArgs)
Dim uploadedFiles As HttpFileCollection = Request.Files
Dim Path As String = Server.MapPath(saveToFolder)
Dim i As integer
For i=0 To uploadedFiles.Count-1
Dim F As HttpPostedFile = uploadedFiles(i)
If ( (Not IsDBNull(uploadedFiles(i))) And (F.ContentLength > 0) ) Then
Dim newName As String = F.FileName.Substring(F.FileName.LastIndexOf("/") + 1)
F.SaveAs(Path + "/" + newName)
End If
Next
End Sub
</script>
< %@ Import Namespace = Namespace="System.IO" %>
<script language="VB" runat="server">
Dim saveToFolder As String = "images"
Protected Sub Page_Load()Sub Page_Load(Src As object, E As EventArgs)
Dim uploadedFiles As HttpFileCollection = Request.Files
Dim Path As String = Server.MapPath(saveToFolder)
Dim i As integer
For i=0 To uploadedFiles.Count-1
Dim F As HttpPostedFile = uploadedFiles(i)
If ( (Not IsDBNull(uploadedFiles(i))) And (F.ContentLength > 0) ) Then
Dim newName As String = F.FileName.Substring(F.FileName.LastIndexOf("/") + 1)
F.SaveAs(Path + "/" + newName)
End If
Next
End Sub
</script>