Solved

PHP access a Mapped network drive running on Xampp

Posted on 2009-07-14
4
1,502 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
The viewer will learn how to count occurrences of each item in an array.

627 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