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

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>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值