Jump to content


file_put_contents() not functioning correctly

  • Please log in to reply
2 replies to this topic

#1 Darkr



  • Member
  • Pip
  • 2 posts
  • Main OS: Windows Vista

Posted 02 December 2007 - 02:50 PM

Hi all, just got Uniform Server downloaded and running, very easy indeed.

Although I am having a small problem with file_put_contents(). I have created a php page that generates a web site from a xml file... when I ran the script it all went ok, the files were created and could be viewed via localhost. But when I looked in the 'www' folder they didn't exsist.

I finally found the files in "C:\Users\Darkr\AppData\Local\VirtualStore\Program Files\Uniform Server\udrive\www"

So I have solved the problem, but I would prefer if the files went to uniform server's virtual drive or the install directory. Is this possible?

#2 Ric


    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 02 December 2007 - 05:49 PM

I donít think itís a UniServer problem!
The command will write a file relative to the folder where the script is run.
For example if you put this into www name it test1.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<p>Echo will display number of characters in the string "33"</p>
echo file_put_contents("test.txt","Pick this file up in www. Testing");

It will create file test.txt in www

The only conflict is if you have a file name that is identical to one on the include path.

It could be the script that is setting that path!

All the best
Ric :D

#3 Darkr



  • Member
  • Pip
  • 2 posts
  • Main OS: Windows Vista

Posted 02 December 2007 - 10:05 PM

Well your right, its definatly not a UniServer problem.

I was going to do your example to make sure it wasnt a path problem, when I got to saving the file in Notepad++ i could see the files, but I cannot see the files when going through file manager. I also noticed a 'compatibility files' button on file manager, once clicked it takes me to the folder mentioned previously.

So i guess its time to read up on vistas features :/

Thanx for your quick reply

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users