we have checked the posted file of the FileUpload and pass it to the IsImageFile() method that returns a Boolean type for checking the actual type of the posted file. If the file contains image extension such as “jpg”, “gif”, “bmp” and “png” then it will return TRUE else it will return false.
- private void StartUpLoad()
- {
- if (FileUpload1.HasFile)
- {
- HttpPostedFile postedFile = FileUpload1.PostedFile;
- if (IsImageFile(postedFile))
- {
- //Save image here
- }
- else
- {
- Response.Write("Invalid File, Cannot Upload!");
- }
- }
- else
- {
- Response.Write("Please select a File");
- }
- }
- protected bool IsImageFile(HttpPostedFile file)
- {
- bool isImage = false;
- System.IO.FileStream fs = new System.IO.FileStream(file.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
- System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
- string fileclass = "";
- byte buffer;
- try
- {
- buffer = br.ReadByte();
- fileclass = buffer.ToString();
- buffer = br.ReadByte();
- fileclass += buffer.ToString();
- }
- catch
- {
- return false;
- }
- finally
- {
- br.Close();
- fs.Close();
- }
- /*extension lists with codes
- *7173 gif
- *255216 jpg
- *13780 png
- *6677 bmp
- *239187 txt,aspx,asp,sql
- *208207 xls.doc.ppt
- *6063 xml
- *6033 htm,html
- *4742 js
- *8075 xlsx,zip,pptx,mmap,zip
- *8297 rar
- *01 accdb,mdb
- *7790 exe,dll
- *64101 bat
- */
- //only allow images jpg gif bmp png
- String[] fileType = { "255216", "7173", "6677", "13780" };
- for (int i = 0; i < fileType.Length; i++)
- {
- if (fileclass == fileType[i])
- {
- isImage = true;
- break;
- }
- }
- return isImage;
- }
而且直接配置文件是效率最高的,通过其它驱动效率都相对较低,BDB
这个测试不太准确,看官方的测试结果:http://bind-dlz.sourceforg
为什么使用BDB时QPS这么低? 我在bind版本基本相似的环境中测试的
It is quite useful and interesting too.
VIRT 的上限是64G,也就是36位, cat /proc/cpuinfo的结果是:addre
昨天要准备用线程重写webbench,试验了下Fedora Linux 2.6.35.14
不明白您的具体的意思是什么?
已经发送到你QQ邮箱