Click here to get back home

file_put_contents problem

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
file_put_contents problem ^AndreA^ 06-25-2008
Posted by ^AndreA^ on June 25, 2008, 11:42 am
Please log in for more thread options
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</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://
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...

Posted by =?ISO-8859-1?Q?=22=C1lvaro_G=2 on June 25, 2008, 12:23 pm
Please log in for more thread options
^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</b> on 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
--

Posted by suhasdhoke@gmail.com on June 26, 2008, 1:04 am
Please log in for more thread options
On Jun 25, 9:23 pm, "=C1lvaro G. Vicario"
> ^AndreA^ escribi=F3:
>
> > <b>Warning</b>: file_put_contents(RSS_news/bbc.xml) [<a
> > href=3D'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</b> on 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- =C1lvaro G. Vicario - Burgos, Spain
> -- Mi sitio sobre programaci=F3n web:http://bits.demogracia.com
> -- Mi web de humor al ba=F1o Mar=EDa: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).


Posted by C. (http://symcbean.blogspot.c on June 26, 2008, 8:33 am
Please log in for more thread options
wrote:
> On Jun 25, 9:23 pm, "=C1lvaro G. Vicario"
>
>
>
> > ^AndreA^ escribi=F3:
>
> > > <b>Warning</b>: file_put_contents(RSS_news/bbc.xml) [<a
> > > href=3D'function.file-put-contents'>function.file-put-contents
>
> > > </a>]: failed to open stream: No such file or directory in <b>/var/ww=
w/
> > > Eclipse/thebigone/server_scripts
>
> > > /rss_bbc.php</b> on line <b>9</b><br />"
>
> > Does PHP have permission to create files in
> > "/var/www/exist/Eclipse/thebigone/server_scripts"? If PHP runs as Apach=
e
> > 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-=C1lvaro G. Vicario - Burgos, Spain
> > -- Mi sitio sobre programaci=F3n web:http://bits.demogracia.com
> > -- Mi web de humor al ba=F1o Mar=EDa: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.

Similar ThreadsPosted
Problem of php_ldap.dll in appserv 2.4.3 and Problem of Apache server in appserv 2.5.3 January 27, 2005, 7:53 pm
PHP with WML problem July 26, 2004, 10:27 pm
Var problem ... September 9, 2004, 9:25 pm
BIG problem. January 17, 2005, 7:05 pm
css problem February 28, 2005, 5:44 pm
Problem April 11, 2005, 5:05 pm
Problem.... May 31, 2005, 10:37 pm
Can anyone help me with this problem please....? July 14, 2005, 11:41 pm
php.ini problem October 20, 2005, 4:44 am
A problem with '"' October 22, 2005, 2:29 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap