PHP cannot open local file when called from outside

I am using the WorldPay payment gateway on the website I am working on. It handles all the credit card credentials and then calls the PHP file on my server with the transaction information. It grabs the output from my script and displays it in chrome WorldPay.

I don't know the inner workings, but my guess is that they will use something similar to cURL to publish the transaction data to my script and then fetch the output.

My script writes the required information to an XML file, sends an email, and then thanks the customer for purchasing from us.

My problem is that when I test my file by calling it directly (disabling security checks and visiting http://example.com/mysite/myscript.php

in my browser) everything works as planned, however when I go through the payment processor (this is how I assumed my script is being called via cURL), it doesn't work on this line:

$xml = simplexml_load_file('./info.xml');

      

Any ideas?

Clarification: This line returns false which splits the following lines.

0


source to share


3 answers


This might be a stretch, but check out one of the number one-on-one misunderstandings with relative path resolution.

'./' 

      

refers to any entry point, not a script, so I use



dirname(__FILE__).'/' 

      

everywhere.

+1


source


Check your HTTP error logs - make sure they are enabled.



It could be something like a file reading problem.

+1


source


Are you sure the path to the info.xml

correct one? This sometimes happens when I include a file from a subdirectory.

0


source







All Articles