我正在尝试为项目构建一个小型CMS。部分原因是,当您点击save-button
时,您的当前修改将会被保存。
$('.save-button').click(function() {
var speisekarte_content = $(".speisekarte-content").html();
console.log(speisekarte_content);
var ajaxurl = 'save.php',
data = {
'content': speisekarte_content
};
$.post(ajaxurl, data, function(response) {
alert("action performed successfully");
});
});
save.php看起来像这样:
<?php
$post_data = $_POST['content'];
if (function_exists('fopen')) {
if (!empty($post_data)) {
$filename = 'speisekarte-content.php';
$handle = fopen($filename, "w");
fwrite($handle, $post_data);
fclose($handle);
echo $file;
}
};
?>
所以它基本上只是将应该保存的内容添加到名为speisekarte-content.php
的文件中...这在localhost上完美运行 - 直到我将它上传到我的nginx服务器并且它停止按预期工作。
这是我在javascript控制台中找到的错误日志:
POST
http://www.myurl.com/editable/save.php net::ERR_TIMED_OUT
k.cors.a.crossDomain.send @ jquery.min.js:4
n.extend.ajax @ jquery.min.js:4
n.(anonymous function) @ jquery.min.js:4
(anonymous function) @ main.js:99
nginx错误日志如下
2015/06/22 08:43:45 [error] 6804#0: *63817 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: content in /var/www/myurl.com/html/editable/save.php on line 2
PHP message: PHP Warning: fopen(autosave.php): failed to open stream: Permission denied in /var/www/myurl.com/html/editable/save.php on line 27
PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/myurl.com/html/editable/save.php on line 28
PHP message: PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/myurl.com/html/editable/save.php on line 29
PHP message: PHP Notice: Undefined variable: file in /var/www/myurl.com/html/editable/save.php on line 30" while reading response header from upstream, client: 176.0.1.54, server: myurl.com, request: "POST /editable/save.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.myurl.com", referrer: "http://www.myurl.com/editable/"
这与nginx或我的代码有关吗?
答案 0 :(得分:0)
你的日志说你的申请没有权利在他目前的阵地中写作。
您应该检查文件中的权利
你可以在应用程序的文件夹中发布ls -al
的输出吗?