【发布时间】:2013-11-30 04:39:34
【问题描述】:
我正在尝试实现一个按钮,单击该按钮会将通用文件上传到 Google 驱动器。以下代码在我的本地机器上运行良好(使用 Google 的本地开发 SDK),但是当上传到 Google App Engine 时,它无法通过 slowtest.php 中的 require_once 语句。这是我的代码:
HTML 文件:
<head>
...
<script src="js/data.js"></script>
...
</head>
<body>
<div class="container">
<h2>Data Page</h2>
<p>Press the button to upload a file.</p>
<button onclick="upload()" style="margin-bottom: 5px;">Upload</button>
<p>Return: <span id="uploadedFiles"></span></p>
</div>
</body>
在这里调用upload():
function upload() {
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("uploadedFiles").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "slowtest.php", true);
xmlhttp.send();
}
最后是 php 文件:
<?php
require_once 'google-api-php-client/src/Google_Client.php';
echo 'success!';
?>
如果我删除“require_once”行,则“成功”会添加到网页上的段落行。但是,当它没有被注释掉时,单击按钮时什么也不会发生。
页面没有错误输出,但是向控制台输出了500错误。
加载资源失败:服务器响应状态为 500 (Internal Server Error)
我已经在命令行上运行了相同的代码并且它可以工作。如果有人有任何建议,他们将不胜感激。
【问题讨论】:
-
您的应用程序目录中是否确实有一个 google-api-php-client 目录,与您的 app.yaml 处于同一级别?
-
感谢您的回复,伊恩。文件夹肯定在那里。我尝试将 google-api-php-client/src 库中的文件与其他所有内容一起移动到主文件夹中,因为在 googles 文件中,他们提到了以“contrib/afile.php”或“auth/anotherfile”的形式包含的内容.php' 等,并且可能找不到这些文件。不过仍然有同样的错误。
标签: php ajax google-app-engine