PHP fopen()创建没有权限修改文件的文件(PHP fopen() creating file without permissions to modify it)
从apache调用的PHP脚本执行以下操作:
$h = fopen(getcwd()."tmp.txt","w"); fprintf($h,"hi"); fclose($h);
生成一个拥有644权限的个人用户ID所拥有的文件。 但是,再次执行脚本会导致错误,因为Apache / PHP以用户wwwrun身份运行,因此没有权限覆盖文件或chmod它。
放置文件的目录位于我的主目录中,具有777权限。 如何让PHP创建由wwwrun拥有的文件,或者使用666权限创建它,或者执行其他操作,以允许它被PHP覆盖。
我理想地寻找一种解决方案,该解决方案也适用于PHP通过使用
exec
函数调用的外部程序创建文件的情况; 这似乎遇到了同样的问题,因为外部程序以wwwrun运行,但外部程序创建的文件由我的个人用户ID拥有。Executing the following from a PHP script called by apache:
$h = fopen(getcwd()."tmp.txt","w"); fprintf($h,"hi"); fclose($h);
generates a file owned by my personal userid with 644 permissions. However, executing the script again results in an error, since Apache/PHP is running as user wwwrun and so doesn't have the permissions to overwrite the file or to chmod it.
The directory that the files are being placed is in my home directory and has 777 permissions. How can I get PHP to either create the file as owned by wwwrun, or create it with 666 permissions, or do something else, to allow it to be overwritten by PHP.
I am ideally looking for a solution which also applies to the situation where the file is created by PHP via an external program called with the
exec
function; this seems to suffer from the same problem, in that the external program runs as wwwrun, but files created by the external program are owned by my personal userid.
原文:
最满意答案
在这里找到了问题。 显然,Stripe.createToken()函数采用各种类型的第二个参数。 如果它是一个函数,则将其作为标记化过程的回调调用。 如果它不是一个函数,它被认为是金额(我认为)。
在我的例子中,回调函数是未定义的(错误的命名空间),因此createToken函数假定它是一个金额,它无法做任何事情,因此错误。
修复...确保回调函数存在。
Found out the issue here. Apparently the Stripe.createToken() function takes various types of second argument. If it's a function, it's invoked as the callback to the tokenization process. If it's not a function it's assumed to be the amount (I think).
In my case, the callback function was undefined (wrong namespace) so the createToken function assumes it's an amount, which it couldn't do anything with, thus the error.
The fix...make sure the callback function exists.
相关问答
更多-
条带createToken如何验证卡是否无效?(How does stripe createToken verify that the card is not invalid?)[2022-08-30]
当您在客户上创建新卡时,Stripe会自动向银行运行$ 0 / $ 1授权,以确保该卡有效并被接受。 如果银行拒绝授权,他们将完全无法创建卡并返回错误。 这允许您预先捕获过期或拒绝的卡,但即使卡有效,也不能保证未来的费用会成功。 确认这一点的唯一方法是给卡充电,看看银行的回应。 在您的情况下,您需要在发货之前向客户收取货物价格。 一旦收费成功,您确定您将获得资金。 When you create a new card on a customer, Stripe automatically runs a $0 ... -
你的错误涉及你的javascript说你正在使用一个密钥,而你的红宝石说你正在使用一个可发布的密钥,所以我假设你把它们放在哪里你设置#{Koudoku.stripe_publishable_key}" 。 #{Koudoku.stripe_publishable_key}"应该是pk_test_... Your error involves your javascript saying you're using a secret key, and your ruby saying you're using ...
-
下面是一个基于我的经验的快速操作方法 (你可以在这里找到我的虚拟Rails-Stripe集成): 首先,将gem'strip gem 'stripe'添加到Gemfile中。 运行bundle install并重新启动webserver。 创建charges_controller.rb添加charge_customform操作: def charge_customform # Amount in cents @amount = 99 # Get the credit card de ...
-
元数据只能添加到可更新对象。 由于令牌不可更新,因此在创建令牌时无法提供元数据。 根据您要提供的元数据类型,您应该在使用卡令牌创建费用或客户时传递metadata参数。 Metadata can only be added to updatable objects. As tokens are not updatable, you cannot provide metadata when creating a token. Depending on what type of metadata you wan ...
-
好吧,我想通了,或者至少我认为我弄明白了。 我只是将显示类型从块更改为内联块,而IOS Safari似乎更加快乐。 #card-number.form-control { display:inline-block; } 我不确定为什么块不起作用,因为它对我使用的所有其他设备都有效...但它就是它。 Well, I figured it out, or at least I think I figured it out. I just changed the display type from bl ...
-
使用ajax / jquery将stripe.js标记传递给django(Using ajax/jquery to pass stripe.js token to django)[2022-04-15]
首先,我不喜欢你如何使用setOutcome两次,一次用于卡的更改事件,然后再次尝试从条带获取令牌时。 拆分这些东西: stripe.createToken(card, extraDetails).then(function(result) { if(result.error && result.error.message){ // Do something with the errors }else{ // Charge the card d ... -
Stripe.js - 无法读取undefined的属性'stripeToken'(Stripe.js - Cannot read property 'stripeToken' of undefined)[2023-08-27]
我们的请求是在变量req not request 这个var stripeToken = request.body.stripeToken; 应该是var stripeToken = req.body.stripeToken; our request is in the variable req not request this var stripeToken = request.body.stripeToken; should be var stripeToken = req.body.stripeTok ... -
Nicolas在下面是正确的,但由于我使用一次性费用并签署了一份定期计划,我需要在try catch块中包含客户和费用。 try { $customer = Stripe_Customer::create(array( "card" => $token, "plan" => "001", "description" => $description, "email" => $email) ); Stripe_Charge::create(array( "amount" ...
-
在这里找到了问题。 显然,Stripe.createToken()函数采用各种类型的第二个参数。 如果它是一个函数,则将其作为标记化过程的回调调用。 如果它不是一个函数,它被认为是金额(我认为)。 在我的例子中,回调函数是未定义的(错误的命名空间),因此createToken函数假定它是一个金额,它无法做任何事情,因此错误。 修复...确保回调函数存在。 Found out the issue here. Apparently the Stripe.createToken() function takes ...
-
是的,确实如此 ; 文档明确指出,基于客户的令牌创建仅适用于Stripe Connect,并且“只能与OAuth访问令牌或Stripe-Account标头一起使用”。 在该上下文中,您可以传递customer属性。 在任何其他情况下,您只能基于卡片或银行帐户创建令牌。 Yes, it does; the docs clearly state that customer-based token creation is only possible for Stripe Connect and "can only ...