Solved

PHP access a Mapped network drive running on Xampp

Posted on 2009-07-14
4
1,345 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

786 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