473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

file_put_contents problem

Hello everybody,

I'm trying to get a file on the internet and put it on my server...

So, from javascript (AJAX) a call a php function that is simply:

file_put_contents('RSS_news/bbc.xml', file_get_contents('http://
newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml'));

file_get_contents doesn't seem to give any problem...

anyway, this is the response I get:
"<br />

<b>Warning</b>: file_put_contents(RSS_news/bbc.xml) [<a
href='function.file-put-contents'>function.file-put-contents

</a>]: failed to open stream: No such file or directory in <b>/var/www/
Eclipse/thebigone/server_scripts

/rss_bbc.php</bon line <b>9</b><br />"

and line 9 of that file is exactly the unique row of code:
file_put_contents('RSS_news/bbc.xml', file_get_contents('http://
newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml'));

My PHP Version is 5.2.3-1

any idea?!?

thanks in advance
Andrea

PS: the unique thing I need to do with this function is take a file on
the internet and copying it on my server... and then I'll do something
else...
Jun 27 '08 #1
5 10965
^AndreA^ escribió:
<b>Warning</b>: file_put_contents(RSS_news/bbc.xml) [<a
href='function.file-put-contents'>function.file-put-contents

</a>]: failed to open stream: No such file or directory in <b>/var/www/
Eclipse/thebigone/server_scripts

/rss_bbc.php</bon line <b>9</b><br />"
Does PHP have permission to create files in
"/var/www/exist/Eclipse/thebigone/server_scripts"? If PHP runs as Apache
module then the "server_scripts" directory needs to have write
permission for the user Apache runs as (typically "nobody" or "apache").

You can probably change permissions with your FTP client. I suggest you
create a special folder for these downloads so you don't need to make
server_scripts itself writable.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jun 27 '08 #2
On Jun 25, 9:23 pm, "Álvaro G. Vicario"
<alvaroNOSPAMTHA...@demogracia.comwrote:
^AndreA^ escribió:
<b>Warning</b>: file_put_contents(RSS_news/bbc.xml) [<a
href='function.file-put-contents'>function.file-put-contents
</a>]: failed to open stream: No such file or directory in <b>/var/www/
Eclipse/thebigone/server_scripts
/rss_bbc.php</bon line <b>9</b><br />"

Does PHP have permission to create files in
"/var/www/exist/Eclipse/thebigone/server_scripts"? If PHP runs as Apache
module then the "server_scripts" directory needs to have write
permission for the user Apache runs as (typically "nobody" or "apache").

You can probably change permissions with your FTP client. I suggest you
create a special folder for these downloads so you don't need to make
server_scripts itself writable.

--
--http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor al baño María:http://www.demogracia.com
--
First confirm, the file (in which you are trying to put the xml
contents) is exists to the mentioned location,
if YES then, Apache should have the permission to write in that file.
(Give the write permission to the file).

Jun 27 '08 #3
On Jun 26, 6:04 am, "suhasdh...@gmail.com" <suhasdh...@gmail.com>
wrote:
On Jun 25, 9:23 pm, "Álvaro G. Vicario"

<alvaroNOSPAMTHA...@demogracia.comwrote:
^AndreA^ escribió:
<b>Warning</b>: file_put_contents(RSS_news/bbc.xml) [<a
href='function.file-put-contents'>function.file-put-contents
</a>]: failed to open stream: No such file or directory in <b>/var/www/
Eclipse/thebigone/server_scripts
/rss_bbc.php</bon line <b>9</b><br />"
Does PHP have permission to create files in
"/var/www/exist/Eclipse/thebigone/server_scripts"? If PHP runs as Apache
module then the "server_scripts" directory needs to have write
permission for the user Apache runs as (typically "nobody" or "apache")..
You can probably change permissions with your FTP client. I suggest you
create a special folder for these downloads so you don't need to make
server_scripts itself writable.
--
--http://alvaro.es-Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor al baño María:http://www.demogracia.com
--

First confirm, the file (in which you are trying to put the xml
contents) is exists to the mentioned location,
if YES then, Apache should have the permission to write in that file.
(Give the write permission to the file).
I expect he'll sat it does - but is looking in the wrong place.

OP: try using the absolute path in the fn call.

C.
Jun 27 '08 #4
On Jun 26, 1:33 pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On Jun 26, 6:04 am, "suhasdh...@gmail.com" <suhasdh...@gmail.com>
wrote:
On Jun 25, 9:23 pm, "Álvaro G. Vicario"
<alvaroNOSPAMTHA...@demogracia.comwrote:
^AndreA^ escribió:
<b>Warning</b>: file_put_contents(RSS_news/bbc.xml) [<a
href='function.file-put-contents'>function.file-put-contents
</a>]: failed to open stream: No such file or directory in <b>/var/www/
Eclipse/thebigone/server_scripts
/rss_bbc.php</bon line <b>9</b><br />"
Does PHP have permission to create files in
"/var/www/exist/Eclipse/thebigone/server_scripts"? If PHP runs as Apache
module then the "server_scripts" directory needs to have write
permission for the user Apache runs as (typically "nobody" or "apache").
You can probably change permissions with your FTP client. I suggest you
create a special folder for these downloads so you don't need to make
server_scripts itself writable.
--
--http://alvaro.es-Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor al baño María:http://www.demogracia.com
--
First confirm, the file (in which you are trying to put the xml
contents) is exists to the mentioned location,
if YES then, Apache should have the permission to write in that file.
(Give the write permission to the file).

I expect he'll sat it does - but is looking in the wrong place.

OP: try using the absolute path in the fn call.

C.
ARGHHHHHHH... damn me!!!

thanks to your comments I found out the problem...

"/var/www/exist/Eclipse/thebigone/server_scripts" did not have write
permission for PHP... but because I didn't want write the file there
but in another folder (RSS_news) at the same lavel of
server_scripts...

So the mistake was in the path... "../RSS_news/bbc.xml" instead of
"RSS_news/bbc.xml"
file_put_contents("../RSS_news/bbc.xml", file_get_contents('http://
newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml'));

I don't know why I thought the path was absolute instead of
relative!!!

Cheers guys!!! ;-)
Jun 27 '08 #5
On Jun 26, 1:33 pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On Jun 26, 6:04 am, "suhasdh...@gmail.com" <suhasdh...@gmail.com>
wrote:
On Jun 25, 9:23 pm, "Álvaro G. Vicario"
<alvaroNOSPAMTHA...@demogracia.comwrote:
^AndreA^ escribió:
<b>Warning</b>: file_put_contents(RSS_news/bbc.xml) [<a
href='function.file-put-contents'>function.file-put-contents
</a>]: failed to open stream: No such file or directory in <b>/var/www/
Eclipse/thebigone/server_scripts
/rss_bbc.php</bon line <b>9</b><br />"
Does PHP have permission to create files in
"/var/www/exist/Eclipse/thebigone/server_scripts"? If PHP runs as Apache
module then the "server_scripts" directory needs to have write
permission for the user Apache runs as (typically "nobody" or "apache").
You can probably change permissions with your FTP client. I suggest you
create a special folder for these downloads so you don't need to make
server_scripts itself writable.
--
--http://alvaro.es-Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor al baño María:http://www.demogracia.com
--
First confirm, the file (in which you are trying to put the xml
contents) is exists to the mentioned location,
if YES then, Apache should have the permission to write in that file.
(Give the write permission to the file).

I expect he'll sat it does - but is looking in the wrong place.

OP: try using the absolute path in the fn call.

C.
C. I didn't see your post before...
relative path is fine, but... I needed the right path!!!

cheers
Andrea
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Preminger | last post by:
Hello! We are running php 4.3.10 Therefore I need to use php_put_contents through pear. Thats what my file looks like: <?php require_once 'php/Compat/Function/file_put_contents.php';
0
by: Börni | last post by:
Hello, I am using tidy to clean up an xml file, but my problem is that it replaces newlines with normal whitespaces. Still worse is that if i retrieve text from the xml file it contains all...
20
by: Pete Marsh | last post by:
Wondering if anyone can see an error with this script. I get a server configuration error. THat could mean a module is not being loaded, but maybe there's a syntax error here, can anyone spot it?...
5
by: Mohawk Mawk | last post by:
Hey guys... I have a image string I want to read with exif_read_data() but exif_read_data() does not read strings, only files. i can display the picture via php Header( "Content-type:...
7
by: amygdala | last post by:
Hi, I'm trying to let PHP write a 'sitemap.xml' sitemap for Google and other searchengines. It's working, except that the content in the XML file doesn't seem to be UTF8. (Which it should be,...
4
by: cookspyder | last post by:
I have a PHP file that when i run the code on my test server(wamp) writes everything in one stream in the file. On win 2003 server IIS I get strange hard returns and spacing between some of the...
9
moishy
by: moishy | last post by:
When I try to write to file like this: file_put_contents("test.txt","Hello World"); I get an error: Fatal error: Call to undefined function: file_put_contents() File_get_contents works...
5
by: petershaman | last post by:
Hi I have a gorgeous flash image gallery, it would work perfectly fine but there's a small problem I can't upload anything thru it's upload script, since I'm getting an error 403. It's so because...
3
by: luttkens | last post by:
All of a sudden I have discovered that it is no longer possible to create files on my server by running php scripts. When I call the function file_put_contents() it returns false. It worked...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.