使aspx页面能接受HTML,asp的页面传送的文件[3]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

  string[] allowedExt = new string[] { }, denyedExt = new string[] { };
  string savePath = String.Empty;
  long maxSize = 10000;
  string type = Request.QueryString["Type"];
  if(type!=null&&type!=string.Empty)
   type=type.ToLower();
  else
   type="file";
  if (type == "image")
  {
   GetConfig("image", out allowedExt, out denyedExt, out savePath,out maxSize);   
  }
  if (type == "file")
  {
   GetConfig("file", out allowedExt, out denyedExt, out savePath, out maxSize);   
  }
  if (type == "flash")
  {
   GetConfig("flash", out allowedExt, out denyedExt, out savePath, out maxSize);  
  }
  if (savePath == string.Empty||savePath=="")
   savePath = "~/UserFiles/";
  if(!savePath.EndsWith("/"))savePath+="/";
  /*********************************************************************************
  byte[] bytes1 = System.Text.Encoding.Default.GetBytes("这是字符串\n\n\n\n");
  byte[] bytes2 = new byte[] { 1, 33, 23, 3, 0, 56, 55, 235, 5 };//二进制数

  byte[] bytes = new byte[bytes1.Length + bytes2.Length];

  //合并二进制流
  MemoryStream ms = new MemoryStream(bytes);
  ms.Write(bytes1, 0, bytes1.Length);
  ms.Write(bytes2, 0, bytes2.Length);

  int count = 0, pos = 0;
  //开始找四个'\n'
  for (int i = 0; i < bytes.Length; i++)
  {
   if (bytes[i] == (int)'\n')
   {
    count++;
    if (count == 4)
    {
     pos -= 4;
     break;
    }
   }
  }

  if (count == 4)
  {
   //这里,bytes字节数组里从0 到 pos 的位置就是你要的字符串
   //从pos + 5 开始到最后,就是你要的二进制
  }
  **********************************************************************************/
  byte[] fileData, formData;

  formData = Request.BinaryRead(Request.ContentLength);
  string head = String.Empty;
  Encoding encoding = Encoding.UTF8;

本文关键:使aspx页面能接受HTML,asp的页面传送的文件
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top