Jump to content
The Uniform Server Community

file_put_contents() not functioning correctly


Darkr
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
</head>
<body>
<h1>Test</h1>
<p>Echo will display number of characters in the string "33"</p>
<?php
echo file_put_contents("test.txt","Pick this file up in www. Testing");
?> 
</body>
</html>

 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...