我用Flash访问xxx.php,获取数据,其中包括一个文件的下载地址。原来工作一直很正常,后来下载文件分布到两台服务器上,对xxx.php进行了修改,使用remote_file_exists函数,判断文件是否在A服务器上,如果不在,就在B服务器上,以此提供文件的下载地址。问题来了,使用remote_file_exists后,Flash访问xxx.php文件出错了,说该文件无法访问……各位有遇到过这种现象的吗?感谢您的帮助!

解决方案 »

  1.   

    remote_file_exists 自己写的函数 你不贴出来的话 这么问 别人也无法帮你。问题应该出在remote_file_exists无法正确的返回结果。借花献佛 自己试看看
    // CHECK REMOTE FILE EXISTS
    function remote_file_exists($url_file){
        $url_file = trim($url_file);
        if (empty($url_file)) return false;
        $url_arr = parse_url($url_file);
        if (!is_array($url_arr) || empty($url_arr)) return false;
        $host = $url_arr['host'];
        $path = $url_arr['path'] ."?".$url_arr['query'];
        $port = isset($url_arr['port']) ?$url_arr['port'] : "80";
        $fp = fsockopen($host, $port, $err_no, $err_str,30);
        if (!$fp) return false;
        $request_str = "GET ".$path." HTTP/1.1\r\n";
        $request_str .= "Host:".$host."\r\n";
        $request_str .= "Connection:Close\r\n\r\n";
        fwrite($fp,$request_str);
        //fread replace fgets
        $first_header = fread($fp, 128);
        fclose($fp);
        if (trim($first_header) == "") return false;
        //check $url_file "Content-Location"
        if (!preg_match("/200/", $first_header) || preg_match("/Location:/", $first_header)) return false;
        return true;
    }
      

  2.   

    好啦,谢谢版主。
    我被忽悠了,PHP是别人写的,他说remote_file_exists是PHP自带的函数,没有去验证,汗~~~~
      

  3.   


    这个方法不是php内置的,所以一定是自定义的,要调试只能进入该方法里面去一步步调试了