Flash 8上传,用C#.net或VB.net做后台程序

本文介绍如何使用Flash8的ActionScript实现文件上传功能,并提供了C#与VB两种语言编写的ASP.NET后端处理示例,用于接收并保存上传的文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>

以下是用VB写的 upload.aspx

<%@ Page Language="VB" ResponseEncoding="utf-8" %>
<%@ Import Namespace="System.IO" %>

<script language="VB" runat="server">
    
Dim saveToFolder As String = "images"

    
Protected 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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值