flash8上传功能的后台程序收集

1.Coldfusion


<cfprocessingdirective pageencoding="utf-8">
<cfcontent type="text/html; charset=utf-8">
<cfset setEncoding("URL", "utf-8")>
<cfset setEncoding("Form", "utf-8")>
<cfset serverPath = "D:/wwwroot/srcfile/">
<cffile action="upload" filefield="form.Filedata" nameconflict="Overwrite" destination="#serverPath#">

2.ASP.Net


string saveToFolder = "savedFiles"
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); 
     } 
   }
}

3.PHP

<?php
//path to storage
$storage = 'userUploads';
//path name of file for storage
$uploadfile = "$storage/" . basename(

INSERT:CONTENT:END FILES['Filedata']['name'] );
//if the file is moved successfully
if ( move_uploaded_file(

INSERT:CONTENT:END FILES['Filedata']['tmp_name'] , $uploadfile ) ) {
  echo( '1 ' .

INSERT:CONTENT:END FILES['Filedata']['name']);
//file failed to move
}else{
  echo( '0');
}
? >

 

有关ASP.NET上传后台程序(修正版)

代码:
=================================================
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat=server>
//上传目录设置;
string saveToFolder = "saveFiles";
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>
=================================================
把上传代码保存成upload.aspx文件就可以了;

注意点
1、要把“上传目录”的安全属性设置成允许“ASPNET”用户写入操作的权限;
2、要在“Web.config”文件内添加“<httpRuntime maxRequestLength="122880" executionTimeout="10000" />”来设置上传文件的大小限制,默认上传文件大小只有4M;
3、有关httpRuntime参数说明:
  maxRequestLength:指示 ASP.NET 支持的HTTP方式上载的最大字节数。该限制可用于防止因用户将大量文件传递到该服务器而导致的拒绝服务攻击。指定的大小以 KB 为单位。默认值为 4096 KB (4 MB)。executionTimeout:指示在被 ASP.NET 自动关闭前,允许执行请求的最大秒数。在当文件超出指定的大小时,如果浏览器中会产生 DNS 错误或者出现服务不可得到的情况,也请修改以上的配置,把配置数加大。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值