{"id":772,"date":"2011-11-18T00:11:54","date_gmt":"2011-11-17T16:11:54","guid":{"rendered":""},"modified":"2014-03-11T22:40:47","modified_gmt":"2014-03-11T14:40:47","slug":"%e5%bf%85%e9%a1%bb%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84asp%e4%b8%8a%e4%bc%a0%e6%bc%8f%e6%b4%9e","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2011\/11\/18\/772.htm","title":{"rendered":"\u5fc5\u987b\u8981\u6ce8\u610f\u7684ASP\u4e0a\u4f20\u6f0f\u6d1e"},"content":{"rendered":"<p>\u6211\u4eec\u4e00\u5b9a\u542c\u8bf4\u8fc7<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/wangzhankaifa\/asp\/\" target=\"_blank\"><font color=\"#333333\">ASP<\/font><\/a>\u7684<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/tag\/%C9%CF%B4%AB\/\" target=\"_blank\"><font color=\"#333333\">\u4e0a\u4f20<\/font><\/a>\u6f0f\u6d1e\uff0c\u539f\u7406\u5c31\u662f\u5c06\u4e00\u4e9b\u6728\u9a6c\u6587\u4ef6\u4fee\u6539\u540e\u7f00\u540d\uff08\u4fee\u6539\u4e3a<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/tuxiangsheji\/\" target=\"_blank\"><font color=\"#333333\">\u56fe\u50cf<\/font><\/a>\u6587\u4ef6\u540e\u7f00\uff09\uff0c\u8fdb\u884c\u4e0a\u4f20\u3002<br \/>\n<u>\u6ce8\u610f\uff1aCheckFileType\u5e76\u4e0d\u80fd\u5224\u65ad\u51fa\u4f2a\u88c5\u6210GIF89a\u7684\u6587\u4ef6\u3002<\/u><\/p>\n<p>\u9488\u5bf9\u6b64\u60c5\u51b5\u4f7f\u7528\u4e0b\u5217\u51fd\u6570\u8fdb\u884c\u8fa8\u522b\uff1a<\/p>\n<p>&lt;% <br \/>\n&#8216;****************************************************************** <br \/>\n&#8216;CheckFileType \u51fd\u6570\u7528\u6765\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u4e3a\u56fe\u7247\u6587\u4ef6 <br \/>\n&#8216;\u53c2\u6570filename\u662f\u672c\u5730\u6587\u4ef6\u7684\u8def\u5f84 <br \/>\n&#8216;\u5982\u679c\u662f\u6587\u4ef6jpeg,gif,bmp,png\u56fe\u7247\u4e2d\u7684\u4e00\u79cd\uff0c\u51fd\u6570\u8fd4\u56detrue\uff0c\u5426\u5219\u8fd4\u56defalse <br \/>\n&#8216;******************************************************************<\/p>\n<p>const adTypeBinary=1<\/p>\n<p>dim jpg(1):jpg(0)=CByte(&amp;HFF):jpg(1)=CByte(&amp;HD8) <br \/>\ndim bmp(1):bmp(0)=CByte(&amp;H42):bmp(1)=CByte(&amp;H4D) <br \/>\ndim png(3):png(0)=CByte(&amp;H89):png(1)=CByte(&amp;H50):png(2)=CByte(&amp;H4E):png(3)=CByte(&amp;H47) <br \/>\ndim gif(5):gif(0)=CByte(&amp;H47):gif(1)=CByte(&amp;H49):gif(2)=CByte(&amp;H46):gif(3)=CByte(&amp;H39):gif(4)=CByte(&amp;H38):gif(5)=CByte(&amp;H61)<\/p>\n<p>function CheckFileType(filename) <br \/>\non error resume next <br \/>\nCheckFileType=false <br \/>\nfilename=LCase(filename)<br \/>\ndim fstream,fileExt,stamp,i <br \/>\nfileExt=mid(filename,InStrRev(filename,&quot;.&quot;)+1) <br \/>\nset fstream=<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/fuwuqi\/\" target=\"_blank\"><font color=\"#333333\">Server<\/font><\/a>.createobject(&quot;ADODB.Stream&quot;) <br \/>\nfstream.Open <br \/>\nfstream.Type=adTypeBinary <br \/>\nfstream.LoadFromFile filename <br \/>\nfstream.position=0 <br \/>\n<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/tag\/Select\/\" target=\"_blank\"><font color=\"#333333\">select<\/font><\/a> case fileExt <br \/>\ncase &quot;jpg&quot;,&quot;jpeg&quot; <br \/>\nstamp=fstream.read(2) <br \/>\nfor i=0 to 1 <br \/>\nif ascB(MidB(stamp,i+1,1))=jpg(i) then CheckFileType=true else CheckFileType=false <br \/>\nnext <br \/>\ncase &quot;gif&quot; <br \/>\nstamp=fstream.read(6) <br \/>\nfor i=0 to 5 <br \/>\nif ascB(MidB(stamp,i+1,1))=gif(i) then CheckFileType=true else CheckFileType=false <br \/>\nnext <br \/>\ncase &quot;png&quot; <br \/>\nstamp=fstream.read(4) <br \/>\nfor i=0 to 3 <br \/>\nif ascB(MidB(stamp,i+1,1))=png(i) then CheckFileType=true else CheckFileType=false <br \/>\nnext <br \/>\ncase &quot;bmp&quot; <br \/>\nstamp=fstream.read(2) <br \/>\nfor i=0 to 1 <br \/>\nif ascB(MidB(stamp,i+1,1))=bmp(i) then CheckFileType=true else CheckFileType=false <br \/>\nnext <br \/>\nend select <br \/>\nfstream.Close <br \/>\nset fseteam=nothing <br \/>\nif err.number&lt;&gt;0 then CheckFileType=false <br \/>\nend function <br \/>\n%&gt;<\/p>\n<p>\u90a3\u4e48\u5728\u5e94\u7528\u7684\u65f6\u5019 <br \/>\nCheckFileType(server.mappath(&quot;cnbruce.jpg&quot;)) <br \/>\n\u6216\u8005 <br \/>\nCheckFileType(&quot;F:\/<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/shujixiazai\/jianzhanxiangguan\/\" target=\"_blank\"><font color=\"#333333\">web<\/font><\/a>\/164\/images\/cnbruce.jpg&quot;))<\/p>\n<p>\u53cd\u6b63\u5373\u662f\u68c0\u6d4b\u9a8c\u8bc1\u672c\u5730\u7269\u7406\u5730\u5740\u7684\u56fe\u50cf\u6587\u4ef6\u7c7b\u578b\uff0c\u8fd4\u56de true \u6216 false\u503c<\/p>\n<p>\u6240\u4ee5\u8fd9\u4e2a\u60c5\u51b5\u5e94\u7528\u5728\u56fe\u50cf\u4e0a\u4f20\u4e2d\uff0c\u76ee\u524d\u7684\u529e\u6cd5\u662f\u5148\u5141\u8bb8\u8be5&ldquo;\u4f2a\u56fe\u50cf&rdquo;\u6587\u4ef6\u7684\u4e0a\u4f20\uff0c\u63a5\u7740\u4f7f\u7528\u4ee5\u4e0a\u7684\u81ea\u5b9a\u4e49\u51fd\u6570\u5224\u65ad\u8be5\u6587\u4ef6\u662f\u5426\u7b26\u5408\u56fe\u50cf\u7684\u89c4\u8303\uff0c\u82e5\u662f\u6728\u9a6c\u4f2a\u88c5\u7684\u56fe\u50cf\u6587\u4ef6\u5219FSO\u5220\u9664\u4e4b\uff0c\u6bd4\u5982\uff1a<\/p>\n<p>\nfile.SaveAs Server.mappath(filename) &#8216;\u4fdd\u5b58\u6587\u4ef6 <br \/>\nIf not CheckFileType(Server.mappath(filename)) then <br \/>\n&nbsp;&nbsp;&nbsp; response.write &quot;\u9519\u8bef\u7684\u56fe\u50cf\u683c\u5f0f&quot; <br \/>\n&nbsp;&nbsp;&nbsp; Set fso = CreateObject(&quot;Scr<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/tag\/IP\/\" target=\"_blank\"><font color=\"#333333\">ip<\/font><\/a>ting.FileSystemObject&quot;) <br \/>\n&nbsp;&nbsp;&nbsp; Set ficn = fso.<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/tag\/get\/\" target=\"_blank\"><font color=\"#333333\">Get<\/font><\/a>File(Server.mappath(filename)) <br \/>\n&nbsp;&nbsp;&nbsp; ficn.delete <br \/>\n&nbsp;&nbsp;&nbsp; set ficn=nothing <br \/>\n&nbsp;&nbsp;&nbsp; set fso=nothing <br \/>\n&nbsp;&nbsp;&nbsp; response.end <br \/>\nend if<\/p>\n<p>ASP\u4e0a\u4f20\u6f0f\u6d1e\u8fd8\u5229\u7528&quot;\\0&quot;\u5bf9filepath\u8fdb\u884c\u624b\u811a\u64cd\u4f5c <br \/>\n<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/tag\/HTTP\/\" target=\"_blank\"><font color=\"#333333\">http<\/font><\/a>:\/\/www.cnbruce.com\/<a rel=\"nofollow\" href=\"http:\/\/www.jzxue.com\/tag\/BLOG\/\" target=\"_blank\"><font color=\"#333333\">blog<\/font><\/a>\/showlog.asp?cat_id=32&amp;log_id=635<\/p>\n<p>\u9488\u5bf9\u8fd9\u6837\u7684\u60c5\u51b5\u53ef\u4f7f\u7528\u5982\u4e0b\u51fd\u6570<\/p>\n<p>function TrueStr(fileTrue) <br \/>\nstr_len=len(fileTrue) <br \/>\npos=Instr(fileTrue,chr(0)) <br \/>\nif pos=0 or pos=str_len then <br \/>\nTrueStr=true <br \/>\nelse <br \/>\nTrueStr=false <br \/>\nend if <br \/>\nend function<\/p>\n<p>\n\u63a5\u7740\u5c31\u53ef\u5224\u65ad\u540e\u518d\u505a\u6587\u4ef6\u7684\u4e0a\u4f20<\/p>\n<p>\nif TrueStr(filename)=false then <br \/>\n&nbsp;&nbsp;&nbsp; response.write &quot;\u975e\u6cd5\u6587\u4ef6&quot; <br \/>\n&nbsp;&nbsp;&nbsp; response.end <br \/>\nend if<\/p>\n<p>file.SaveAs Server.mappath(filename)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u4e00\u5b9a\u542c\u8bf4\u8fc7ASP\u7684\u4e0a\u4f20\u6f0f\u6d1e\uff0c\u539f\u7406\u5c31\u662f\u5c06\u4e00\u4e9b\u6728\u9a6c\u6587\u4ef6\u4fee\u6539\u540e\u7f00\u540d\uff08\u4fee\u6539\u4e3a\u56fe\u50cf\u6587\u4ef6\u540e\u7f00\uff09\uff0c\u8fdb\u884c\u4e0a\u4f20\u3002 \u6ce8\u610f\uff1aCheckFileType\u5e76\u4e0d\u80fd\u5224\u65ad\u51fa\u4f2a\u88c5\u6210GIF89a\u7684\u6587\u4ef6\u3002 \u9488\u5bf9\u6b64\u60c5\u51b5\u4f7f\u7528\u4e0b\u5217\u51fd\u6570\u8fdb\u884c\u8fa8\u522b\uff1a &lt;% &#8216;****&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-772","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/comments?post=772"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/772\/revisions"}],"predecessor-version":[{"id":66629,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/772\/revisions\/66629"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=772"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=772"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}