wamp服务器和生产行为不同

时间:2014-11-02 02:33:29

标签: php apache wamp

我的网页允许用户拖放上传输入文件,进行一些操作和转换,然后将输出文件保存到Web服务器上的公共可访问位置。最后,向用户提供指向生成文件的链接。

下面的代码(缩写)在我的WAMP服务器上运行正常但是当我将代码上传到生产主机时,它不再有效。 WAMP Apache版本为2.4.9,WAMP PHP版本为5.5.12。生产服务器是Apache 2.2版和PHP版本5.3.27。我意识到版本不一样 - 这可能是问题吗?我不想弄乱生产服务器的版本,但如果需要,我会这样做。

我已经检查了我的脚本尝试写入的文件夹的Windows权限,并且作为故障排除的一部分已经打开它们以完全控制每个人。 (这实际上是一个内部网络服务器,所以我并不是超级关注)

编辑/更新:根据@Itay Moav -Malimovka的建议,我包括了firebug输出。我是firebug的新手,所以我不完全确定显示结果的最佳方式(显然有大量数据)。

dragover和drop事件似乎没问题。和fileSetup事件一样,发送和输入设置事件(尽管深入挖掘,有很多隐藏的红色和未定义的值)。然后,POST事件在filehandler.php中有500个内部服务器错误。

  • 响应标头
  • 连接关闭
  • 内容长度 0
  • 内容类型 text / html
  • 日期 Sun,02 Nov 2014 03:05:06 GMT
  • 服务器 Apache / 2.2.22(Win32)PHP / 5.3.27
  • 请求标题
  • 接受 text / html,application / xhtml + xml,application / xml; q = 0.9, / ; q = 0.8
  • 接受编码 gzip,deflate
  • 接受语言 en-US,en; q = 0.5
  • 内容 - 长度 h 34124
  • Content-Type application / octet-stream
  • 主机 domain.com
  • Referer http://domain.com/path/index.html
  • 用户代理 Mozilla / 5.0(Windows NT 6.3; WOW64; rv:33.0)Gecko / 20100101 Firefox / 33.0
  • X-File-Date 星期二,2014年9月23日22:10:03 GMT
  • X-File-Name smallInputFile.rdb
  • X-File-Size 34124
  • X-Requested-Wit h FileDrop-XHR-FileAPI

我不确定还要检查什么。接下来你会检查什么?我认为它与服务器设置而不是代码有关(因为它在默认的WAMP服务器上运行)但为了完整性,我在下面包含(缩写)相关代码:

(index.html) - 请注意,在生产服务器上警报甚至不会触发。

<html>
<head>
    <script type="text/javascript" src="includes/ddup/filedrop.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
    <fieldset id="zone">
        <legend>Drop a file inside&hellip;</legend>
        <p>Or click here to <em>Browse</em>..</p>
    </fieldset>
    <span id="status"></span>
    <script type="text/javascript">
        var zone = new FileDrop('zone', options);    
        // Do something when a user chooses or drops a file:
        zone.event('send', function (files) {
        // Depending on browser support files (FileList) might contain multiple items.
        files.each(function (file) {
            // React on successful AJAX upload:
            var p = document.createElement('p');
            zone.el.appendChild(p);
            file.event('done', function (xhr) {
                // 'this' here points to fd.File instance that has triggered the event.
                alert('Done uploading ' + this.name);
                document.getElementById('status').innerHTML=xhr.responseText;
                alert('Done uploading ' + this.name + ', response:\n\n' + xhr.responseText);
        });

            file.event('progress', function (sent, total) {
                p.textContent = 'Uploaded ' + Math.round(sent / total * 100) + '%...';
            })

          // Send the file:
          file.sendTo('fileHandler.php');
        });
      });
       </script>
</body>
</html>

(fileHandler.php)

<?php
/** Error reporting */
error_reporting(E_ALL);

// If an error causes output to be generated before headers are sent - catch it.
ob_start();

/** Include path **/
ini_set('include_path', ini_get('include_path').';../Classes/');

if (!empty($_FILES['fd-file']) and is_uploaded_file($_FILES['fd-file']['tmp_name'])) {
  // Regular multipart/form-data upload.
  $filename = $_FILES['fd-file']['name'];
  $filedata = file_get_contents($_FILES['fd-file']['tmp_name']);
} else {
  // Raw POST data.
  $filename = urldecode(@$_SERVER['HTTP_X_FILE_NAME']);
  $filecontents = file_get_contents("php://input");
  $filedata = explode("\n",$filecontents);
}

//**** do stuff to file ****//


// Save Excel 2007 file
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$fileBase = explode(".",$filename);
$outFilename = $fileBase[0] . date('His') . ".xlsx";
$url = "xlsxFiles/$outFilename";
$objWriter->save($url);
echo "<br><table class=\"rulesTable\" id=\"linkRow\"><tr><td><span id=\"finalLink\">Link to generated XLS file: <a href=\"$url\">$outFilename</a></span></td></tr></table>";

?>

1 个答案:

答案 0 :(得分:1)

您的生产服务器是否正在运行*NIX OS

如果是,这条线可能会引起它抱怨

ini_set('include_path', ini_get('include_path').';../Classes/');

在* NIX中,路径分隔符是冒号:而不是分号;

有一个名为PATH_SEPERATOR的预定义常量,它允许您与操作系统无关,所以请尝试使用

set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
相关问题