AJAX/PHP/Apache 数据传输和文件权限问题
我正在对我正在构建的生物识别相关原型的用户击键模式进行一些分析。我遇到一个问题,我通过 POST 将变量传递到另一个网页,并且该网页调用一个脚本,该脚本根据传递给它的数据写入目录中的本地服务器。
我的原型很简单:用户在文本表单中输入一些数据,收集击键,用户在任务结束时单击“提交”,然后将数据发送到服务器进行分析。然而,PHP 拒绝写入通过网络指定的目录。如果我进入命令行 PHP,它就可以工作。我什至尝试将 insertData 中的 POST 更改为 GET,并手动传递数据。
以下是我认为可能有问题的几件事:
- 我的 AJAX 是错误的。它在本地工作,但在网络上不起作用。然而,我可能无意中改变了一些东西,这就是这个问题的根源。
- 我的 apache 文件权限不正确。但这很奇怪,因为 Apache 拥有相关文件夹/文件。 SELinux 被禁用,所以这是不在列表中的一件事。我什至在有问题的文件夹上尝试了 chmod 777,但无济于事。
- 我缺少 httpd.conf 中的一个指令,并且 apache 只是不允许 Web 写入。
服务器信息:
CentOS 5 阿帕奇2.2 PHP 5.3.6
这里是澄清的源代码。假设所有站点名称等均正确。
http://jyaworski.pastebin.us/2799 GatherData.php
http://jyaworski.pastebin.us/2800 GatherData.js
htt://jyaworski.pastebin.us/2801 //抱歉。所以不会让新手发布超过 2 个链接。在 http 后面加一个“p” InsertData.php
预先感谢您;这个问题已经困扰我一段时间了。
I'm doing some analysis on user keystroke patterns for a biometrics-related prototype that I'm building. I'm having an issue where I pass variables via POST to another webpage, and that webpage calls a script that writes to the local server in a directory based on the data that's passed to it.
My prototype is simple: the user types some data into a text form, the keystrokes are collected, the user clicks submit at the end of the task, and that data is sent off to the server to be analyzed. However, PHP refuses to write to the directory specified via the web. If I go into the command-line PHP, it works. I even tried changing POST to GET in insertData, and passing in the data manually.
Here are a few things I think could be wrong:
- My AJAX is wrong. It worked locally, but doesn't work on the web. However, I could have inadvertently changed something, and that's the source of this issue.
- My file permissions for apache are incorrect. It's odd, though, because Apache owns the folder/file in question. SELinux is disabled, so that's one thing off of the list. I even tried chmod 777 on the folders in question, to no avail.
- There's a directive in httpd.conf that I'm missing, and apache is just not allowing web writes.
Server information:
CentOS 5
Apache2.2
PHP 5.3.6
Here is the source code for clarification. Assume all site names et al are correct.
http://jyaworski.pastebin.us/2799
GatherData.phphttp://jyaworski.pastebin.us/2800
GatherData.jshtt://jyaworski.pastebin.us/2801 //sorry. SO won't let newbies post more than 2 links. Add a "p" to http
InsertData.php
Thank you in advance; this issue has been plaguing me for some time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apache 可能没有“.”的写权限。尝试将其放入 /tmp 中,看看是否可以解决您的问题。如果是这样,请将其保留在那里,或者在您尝试保存数据的目录中添加 apache 的写入权限。
Apache probably doesn't have write permissions on ".". Try putting it in /tmp and see if that fixes your problem. If so leave it there or add write permissions for apache in the directory you're trying to save the data to.