1.我在自己的电脑上(win7)搭建了一个Apache+php+mysql的环境,用的是XAMPP集成环境,需要下载远程服务器(100.1.100.123)上/var/www/pacp/20150810.pcap文件,下载到本地,用wireshark可以正常打开。
-------------------------------------------------------------------------------------------------------
2.然后我在自己的服务器上(debain系统)搭建了一个Apache+php+mysql的环境,同样是下载远程服务器(100.1.100.123)上/var/www/pacp/20150810.pcap文件,下载到本地,打开出错。
-------------------------------------------------------------------------------------------------------
3.具体实现是在浏览器中输入url,
本机对应:localhost/exportfile.php,
服务器对应:100.1.100.100/exportfile.php
下载下来的20150810.pacp文件大小一样,
通过localhost/exportfile.php下载下来的是正常的,用wireshark打开正常显示数据
但是通过100.1.100.100/exportfile.php下载下来的,打开没有数据显示,但是文件大小一样。
------------------------------------------------------------------------------------------------------------------
4.考虑到编码问题,但是更改utf-8、gb2312、或者二进制,还是同样的错误,
本机和服务器上的代码是一样的,都用到了httpcopy这个函数
function httpcopy($url, $file="", $timeout=60) {
$file = empty($file) ? pathinfo($url,PATHINFO_BASENAME) : $file;
$dir = pathinfo($file,PATHINFO_DIRNAME);
!is_dir($dir) && @
mkdir($dir,0755,true);
$url = str_replace(" ","%20",$url);
if(function_exists('curl_init')) {
$ch = curl_init();
// echo $url;
// $this_header = array("content-type: application/x-www-form-urlencoded;charset=UTF-8");
$this_header = array("content-type: application/octet-stream;charset=UTF-8");
curl_setopt($ch,CURLOPT_HTTPHEADER,$this_header);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$temp = curl_exec($ch);
if(@file_put_contents($_SERVER["DOCUMENT_ROOT"] ."/Functional_pages/maintain_management/tcp_report/".$file, $temp) && !curl_error($ch)) {
return $file."rrrrrrrrrrrrr";
} else {
return false;
}
} else {
$opts = array(
"http"=>array(
"method"=>"GET",
"header"=>"",
"timeout"=>$timeout)
);
$context = stream_context_create($opts);
if(@copy($url, $file, $context)) {
//$http_response_header
echo "bbbb";
return $file;
} else {
return false;
}
}
-------------------------------------------------------------------------------------------
5:咋办,求帮助,求指导!!!