Solved

PHP access a Mapped network drive running on Xampp

Posted on 2009-07-14
4
1,306 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
UNC path names did the trick. thank you very much spent ages trying to figure that out.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now