我有两个简单的脚本可以从本地机器上的特定路径上传文件并将其放置在 Apache 服务器上。它在 OSX 10.8 内置的 Apache 上运行良好,但在 CentOS 6 上却不行。这是代码:
http://mysite.mydomain.com/logsend.php?logfilename=logfile.log
然后转到“logsend.php”:
<?php
$logfilename = $_GET['logfilename'];
$target_url = 'http://mysite.mydomain.com/logaccept.php';
$localdir = '/usr/local/mysoftware/logs/';
$logurl = $localdir . $logfilename;
$post = array('extra_info' => '123456','file_contents'=>'@'.$logurl);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch);
?>
然后转到 logaccept.php:
<?php
$uploaddir = realpath('uploads/') . '/';
$uploadfile = $uploaddir . basename($_FILES['file_contents']['name']);
if (move_uploaded_file($_FILES['file_contents']['tmp_name'], $uploadfile)) {
echo "Log file successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
?>
mac按预期在浏览器窗口中返回“日志文件成功上传”,但在CentOS盒子上我只是得到虚无的PHP白屏。Apache error_log 中没有任何错误显示,我不知道如何进一步解决这个问题。
有任何想法吗?我试图将一些调试代码加载到 PHP 文件中,但我仍然只能得到空白:
ini_set('display_errors', 'On');
error_reporting(E_ALL);