fileupload控件的属性_FileUpload控件简介

string FileContentType = _CanUploadFilePattern.ToLower();

FileContentType = FileContentType.Replace("*.gif", "image/gif");

FileContentType = FileContentType.Replace("*.jpg", "image/pjpeg");

FileContentType = FileContentType.Replace("*.bmp", "image/bmp");

FileContentType = FileContentType.Replace("*.avi", "video/avi|video/msvideo|video/x-msvideo");

FileContentType = FileContentType.Replace("*.afl", "video/animaflex");

FileContentType = FileContentType.Replace("*.asf", "video/x-ms-asf");

FileContentType = FileContentType.Replace("*.arj", "application/arj");

FileContentType = FileContentType.Replace("*.rar", "application/x-rar-compressed|application/octet-stream");

FileContentType = FileContentType.Replace("*.zip", "application/zip|multipart/x-zip|application/x-compressed|application/x-zip-compressed");

FileContentType = FileContentType.Replace("*.gz", "application/x-gzip-compressed|application/x-compressed");

FileContentType = FileContentType.Replace("*.wav", "audio/wav|audio/x-wav");

FileContentType = FileContentType.Replace("*.mpg", "audio/mpeg|video/mpeg");

FileContentType = FileContentType.Replace("*.mp3", "video/x-mpeg|audio/mpeg3|audio/x-mpeg-3|video/mpeg");

FileContentType = FileContentType.Replace("*.mpe", "video/mpeg");

FileContentType = FileContentType.Replace("*.pdf", "application/pdf");

FileContentType = FileContentType.Replace("*.rm", "audio/x-pn-realaudio|application/vnd.rn-realmedia");

FileContentType = FileContentType.Replace("*.rmi", "audio/mid");

FileContentType = FileContentType.Replace("*.swf", "application/x-shockwave-flash");

FileContentType = FileContentType.Replace("*.txt", "text/plain");以上代码是:_CanUploadFilePattern是在程序中定义的一个变量,用于设定允许上传文件的类型,然后再将文件类型转换为一串由MIME类型组成的字串,用于比较上传文件是否在设定类型中,这样就可以控制文件上传的类型了;上面代码中可以看到:*gif的MIME类型为:image/gif。,可以在VS中调试方式查看ContentType的值就OK。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值