Link to home
Start Free TrialLog in
Avatar of purpleoak
purpleoakFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PHP access a Mapped network drive running on Xampp

I have a Xampp installation running on windows server 2003. This has a mapped network drive to a text file. I cannot read or even see the file with php (see code) I also tried fopen. I have full access to the file under windows.

I have set the Apache service to run as a domain administrator as a test however this still didn't work. I did this via the MMC service control panel logon as. option.
<?php
//file path of MEFILTER-BANNED.txt
 $filepath = "T:\\Config\\Filters\\Patterns\\MEFILTER-BANNED.txt";
 
 //file path of the log file
 $logpath = "log.txt";
 
 //file path of MEFILTER-BANNEDTEMP.txt
 $filepathtemp = "T:\\Config\\Filters\\Patterns\\MEFILTER-BANNEDTEMP.txt";
 
 if (file_exists($filepath)) {
    echo 'The file is readable';
} else {
    echo 'The file is not readable';
}
 
 
  $fh = fopen($filepath, 'a+') or exit("");
  $stringData = $_POST["domain"];
  fwrite($fh, "$stringData\r\n") or exit("");
  fclose($fh);
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry - should have posted an example

Rather than

$filepath = "T:\\Config\\Filters\\Patterns\\MEFILTER-BANNED.txt";

use

$filepath = "T:/Config/Filters/Patterns/MEFILTER-BANNED.txt";
Avatar of purpleoak

ASKER

I will try the UNC name then however I have tried the forward slash, double single both directions. I perhaps should have mentioned that. Apologies.
UNC path names did the trick. thank you very much spent ages trying to figure that out.