file_put_contents problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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://'));

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

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

/rss_bbc.php</b> on 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://'));

My PHP Version is 5.2.3-1

any idea?!?

thanks in advance

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

Re: file_put_contents problem

^AndreA^ escribió:
Quoted text here. Click to load it

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.

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor al baño María:

Re: file_put_contents problem

On Jun 25, 9:23 pm, "=C1lvaro G. Vicario"
Quoted text here. Click to load it

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).

Re: file_put_contents problem

Quoted text here. Click to load it

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

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


Site Timeline