使用ASP.NET C#将.swf文件上传到数据库 [英] upload .swf file into database using asp.net c#

查看:64
本文介绍了使用ASP.NET C#将.swf文件上传到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发送给我代码,使用asp.net将.swf文件上传到数据库中c#

send me code upload .swf file into database using asp.net c#

推荐答案

后面的代码:
------------
code behind:
------------
string Extension = Path.GetExtension(UploadFile.PostedFile.FileName);
                   if (Extension.ToLower().Trim().ToString() == ".swf")
                   {
                       string fileName = UploadFile.PostedFile.FileName;
                       HttpPostedFile _postedFile = UploadFile.PostedFile;
                       int len =Convert.ToInt32(_postedFile.InputStream.Length);
                       byte[] data = new byte[len];
                       _postedFile.InputStream.Read(data, 0, len);
                   }    


现在,将此数据"字节数组保存到相关的db(任何插入查询或linq查询)中.
在表中将列类型设为"blob"(mysql).

当列数据条目的大小一致(且小于8,000个字节)时,请使用Binary.
当列数据条目的大小相差很大(且小于8,000个字节)时,请使用varBinary.
当列数据条目超过8,000个字节时,请使用varBinary(max).




源代码
-----------


now save this "data" byte array into your related db(any insert query or linq query).
Take column type as "blob"(mysql) in your table.

Use Binary when the sizes of the column data entries are consistent (and less than 8,000 bytes).
Use varBinary when the sizes of the column data entries vary considerably (and are less than 8,000 bytes).
Use varBinary(max) when the column data entries exceed 8,000 bytes.




source code
-----------

<asp:fileupload id="UploadFile" width="500" runat="server" xmlns:asp="#unknown" />


这篇关于使用ASP.NET C#将.swf文件上传到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆