如何在SQL Server的asp.net中仅上载和下载doc和docx文档 [英] How to upload and download only doc and docx document in asp.net in sql server
本文介绍了如何在SQL Server的asp.net中仅上载和下载doc和docx文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何在SQL Server的asp.net中仅上载和下载doc和docx文档.
谢谢你
Mohd Wasif
Hi All,
How to upload and download only doc and docx document in asp.net in sql server.
Thanking You
Mohd Wasif
推荐答案
您不能阻止人们上载他们喜欢的东西,而不是在ASP.NET中,但是您可以在存储文件之前检查文件的有效性.您的数据库.
You can''t stop people uploading whatever they like, not in ASP.NET, but you can check the validity of the files before storing them in your DB.
您可以使用JavaScript来执行此操作,也可以使用正则表达式来获取文件扩展名,如下所示:
You can use JavaScript to do so,you can use regular expression to get file extension like this:
var extens=(/[.]/.exec(myfile)) ? /[^.]+
/.exec(myfile) : undefined;
/.exec(myfile) : undefined;
myfile是文件的地址或路径.这只是将字符串放在."之后. .然后,您可以使用if进行一些控制检查.像:
myfile is the address or the path of the file. This simply takes the part of the string after "." . Then you can place some control checks with if. Something like :
if(extens=="doc" || extens=="docx"|| extens=="xls")
{
//your method goes here
}
else
{
alert("file is invalid");
}
您也可以参考此以获得更多帮助:
http://www.coursesweb.net/javascript/check-file-type-before-upload_t [^ ]
希望对您有所帮助:)
You can also refer to this for more help:
http://www.coursesweb.net/javascript/check-file-type-before-upload_t[^]
hope it helps :)
这篇关于如何在SQL Server的asp.net中仅上载和下载doc和docx文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文