Solved

PHP access a Mapped network drive running on Xampp

Posted on 2009-07-14
4
1,378 Views
Last Modified: 2013-12-13
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

0
Comment
Question by:purpleoak
  • 2
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
ID: 24849497
Two suggestions for you

1. Use forward slashes in the filename and let PHP worry about  translating them to match the file system

2. If possible use UNC names rather than mapped drives  //server/path/to/folder/filename.txt

0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 24849508
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";
0
 
LVL 2

Author Comment

by:purpleoak
ID: 24849539
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.
0
 
LVL 2

Author Closing Comment

by:purpleoak
ID: 31603186
UNC path names did the trick. thank you very much spent ages trying to figure that out.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question