JBTALKS.CC

标题: mime type 辨别~求助 [以解决] [打印本页]

作者: 缘之人    时间: 2012-3-1 05:17 PM
标题: mime type 辨别~求助 [以解决]
本帖最后由 缘之人 于 2012-3-1 08:39 PM 编辑

if($_FILES['userfile']['type'] !='image/vnd.adobe.photoshop' && 'application/postscript') {
    echo "sorry,we only allow PSD / AI FILES";
        exit;
        }


各位大大们~要怎样才能一次过辨认PSD 和 AI file 这2种mime type 呢?
作者: weeming21    时间: 2012-3-1 05:22 PM
if($_FILES['userfile']['type'] !='image/vnd.adobe.photoshop' || $_FILES['userfile']['type'] !='application/postscript') {

大概是这样

你只是验证这个userfile type? 没有做其他验证?
如果但只是这样的验证,分分钟你系统会被上传后门被入侵
作者: 缘之人    时间: 2012-3-1 05:41 PM
回复 2# weeming21


    谢谢大大~~PSD和AI file 的mime type 是那个吗? 我试了好多次都不行   

  我只做了这个 + php,asp 的 preg_match
作者: Super-Tomato    时间: 2012-3-1 07:57 PM
本帖最后由 Super-Tomato 于 2012-3-1 08:12 PM 编辑
if($_FILES['userfile']['type'] !='image/vnd.adobe.photoshop' && 'application/postscript') {
    ech ...
缘之人 发表于 2012-3-1 05:17 PM



mime 類型你已經知道了,那麽就用 php 所提供的 mime_content_type 函數(pear)來做比對


p/s: 剛查了一下 psd 和 ai 的 content-type 是這個
psd = application/octet-stream
ai = application/postscript
作者: 缘之人    时间: 2012-3-1 08:39 PM
回复 4# Super-Tomato


    谢谢大大,成功了




欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) Powered by Discuz! X2.5