Eri*_*tto 9 php linux rest command-line tmp
编辑1
这个问题涉及MANGOPAY API的用户.我的问题是我无法将API写入该tmp文件夹.
我成功地让API写入http://fakedomain.com/apifolder/blank.txt并获得适当的输出.
然后我跑了剧本http://fake.com/apifolder/demos/iswrite.php上http://fakedomain.com/apifolder/blank.txt有最小的工作代码我可以测试的tmp文件夹中.这是脚本中的代码:
<?php
$filename = 'blank.txt';
echo "<br>";
file_exists($filename);
echo "<br>";
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
echo "<br>";
if (is_writable($filename)) {
echo 'The file is writable';
} else {
echo 'The file is not writable';
}
?>
Run Code Online (Sandbox Code Playgroud)
它给了我输出
The file blank.txt exists
The file is writable
所以那里都很好.我使用Filezilla创建了以下具有以下权限的文件:
在脚本中http://fake.com/apifolder/demos/iswrite.php我已将filename变量更改为$filename = 'http://fake.com/tmp/creative/blank.txt';.它给了我以下输出:
The file http://fake.com/tmp/creative/blank.txt does not exist
The file is not writable
此外,allow_url_fopen是.
我不完全理解URL结构,所以问题可能就在那里?我尝试访问的tmp文件夹与我的public_html文件夹位于同一级别.也许我写错了我的网址?
换句话说,tmp文件夹必须在public_html文件夹外吗?这会有什么目的吗?或者我可以tmp在public_html已经工作的位置创建自己的文件夹吗?
原始问题
最初的问题写得不好.请参阅编辑1
我正在玩API的沙箱(MangoPay).我已经包含了我的ClientId和ClientPassword,它似乎有效.
API也说......
您还需要在$ api-> Config-> TemporaryFolder中设置SDK需要存储临时文件的文件夹路径.此路径应位于www文件夹之外.它可以是/ tmp /或/ var/tmp /或PHP可以写入的任何其他位置.
我创建了一个:
ftp://fakedomain@fakedomain/tmp/fakefoldername
我使用终端从桌面运行php脚本.它给我的输出是
无法创建或写入文件
ftp://fakedomain@fakedomain/tmp/fakefoldername
即使我已将权限设置为777.
知道为什么我收到这个错误吗?
if (!is_writable($this->GetPathToTemporaryFolder()))
throw new \MangoPay\Libraries\Exception('Cannot create or write to file ' . $this->GetPathToTemporaryFolder());
Run Code Online (Sandbox Code Playgroud)
所以基本上我们似乎正在调试一个调用is_writable().
allow_url_fopen打开一般来说,临时目录应该与您的代码位于同一台机器上。使用 FTP 不太理想。您无法使用本地目录吗?
您会注意到 MangoPay 文档中显示了本地目录:
https://github.com/Mangopay/mangopay2-php-sdk
$api->Config->TemporaryFolder = '/some/path/';
Run Code Online (Sandbox Code Playgroud)
您可能应该坚持这一点,而不是通过 FTP 使用远程服务器。
| 归档时间: |
|
| 查看次数: |
1837 次 |
| 最近记录: |