无法使用PHP在Google App Engine开发服务器上写入文件? [英] Cannot write to file on Google App Engine Dev server with PHP?

查看:96
本文介绍了无法使用PHP在Google App Engine开发服务器上写入文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在几个小时前就完成了这项工作。不知道我做了什么弄乱了,如果有的话。我正在尝试对我的temp目录中的test.txt文件使用file_put_contents()来测试一些东西。我不能使用print_r()或echo,因为有时它是我正在测试的ajax调用。我不断收到的错误是:

I had this working literally just a few hours ago. Not sure what I did to mess it up, if anything. I am trying to use file_put_contents() to a test.txt file in my temp directory to test some stuff. I can't use print_r() or echo, because sometimes it is an ajax call I am testing. The errors I keep getting are:

Warning: file_put_contents(temp/test.txt): The local filesystem is readonly, open failed in sub-dirs.../request.php on line 62

Warning: file_put_contents(temp/test.txt): failed to open stream: No such file or directory in sub-dirs.../request.php on line 62

我不在生产中。这是本地的,根据文档,这应该可以工作:

I am not on production. This is locally, and according to the docs, this should work:


在开发Web服务器中存储数据

Storing data in the development web server

适用于PHP的Google App Engine支持通过PHP的流API读写Google Cloud Storage。通过将对象指定为支持PHPs Streams实现的任何PHP函数(例如fopen(),fwrite()或get_file_contents())的URI,开发人员可以对其进行读取和写入。

Google App Engine for PHP supports reading and writing to Google Cloud Storage via PHP's streams API. A developer can read to and write from an object in Google cloud storage by specifying it as a URI to any PHP function that supports PHPs Streams implementation such as fopen(), fwrite() or get_file_contents().

在开发服务器中,当指定Google Cloud Storage URI时,我们通过读写用户本地文件系统上的临时文件来模拟此功能。这些文件在请求之间保留,使您可以在将代码部署到App Engine之前测试本地开发环境中的功能。

In the Development Server, when a Google Cloud Storage URI is specified we emulate this functionality by reading and writing to temporary files on the user's local filesystem. These files are preserved between requests, allowing you to test the functionality on your local development environment before deploying your code to App Engine.

在PHP开发服务器中,流调用如fopen(),file_get_contents ()在'gs://'上的网址是通过读写本地文件系统来模拟的。

In the PHP development server streaming calls like fopen(), file_get_contents() on 'gs://' urls are mocked by reading and writing to the local filesystem.

我很沮丧,因此任何帮助都是非常感谢。

I'm pretty frustrated, so any help is greatly appreciate. Will upvote.

推荐答案

Staring SDK 1.9.18,dev_appserver默认情况下会禁用本地文件写入功能,以更好地模拟生产环境。您可以通过在php.ini文件中添加 google_app_engine.disable_readonly_filesystem = 1来启用文件写入功能。

Staring SDK 1.9.18, dev_appserver disables local file writing by default to better simulate the production environment. You can enable file writing by adding "google_app_engine.disable_readonly_filesystem=1" to your php.ini file.

这篇关于无法使用PHP在Google App Engine开发服务器上写入文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆