I have a question regarding why via
php -q -f /home/user/public_html/file.php (this script contain a small script that create a file).
file.php content:
$csvFile = 'http://example.com/file.csv';
function readCSV($csvFile){
$file_handle = fopen($csvFile, 'r');
while (!feof($file_handle) !== FALSE) {
$line_of_text[] = fgetcsv($file_handle, 1024);
}
fclose($file_handle);
return $line_of_text;
}
$csv = readCSV($csvFile);
$xml = new SimpleXMLElement('<data/>');
foreach ($csv as $_item){
$itm = $xml->addChild('produs');
$itm->addAttribute('city', $_item[0]);
$itm->addAttribute('street', $_item[2]);
$itm->addAttribute('number', $_item[3]);
$itm->addAttribute('user', '0');
}
$dom = new DOMDocument();
$dom->loadXML($xml->asXML());
$dom->formatOutput = true;
$formattedXML = $dom->saveXML();
$xmlFilePath = 'file.xml';
//i solved the issue with '/home/path/to/be/stored/'
$fp = fopen($xmlFilePath,'w+');
fwrite($fp, $formattedXML);
fclose($fp);
The issue is that on execute the command the file is not created, but on access on web via http it is created.
There is no error, it just say that the file has been created but is not.
Centos 6 - Minimal Server Nginx, PHP-FPM. User www-data and root, both does the same.
Any help is appreciated.