Page 1 of 1
writing to a directory
Posted: Sat Dec 09, 2006 10:45 am
by corillo181
why this doesn't work?
Code: Select all
<?php
$do=fopen("sing/index.php",'r');
$write='this is all it man';
if($do){
fwrite($do, $write);
}
fclose($do);
?>
Posted: Sat Dec 09, 2006 10:56 am
by corillo181
oh ok i had to use fopen'w' not 'r', but what if i want to throw a whole page full of code do i have to attach it to a variable too ?
Posted: Sat Dec 09, 2006 11:00 am
by feyd
You can write it directly.
Posted: Sat Dec 09, 2006 10:52 pm
by corillo181
yeah but i mean if i got a whole page i want to dumb into another page.
Posted: Sun Dec 10, 2006 3:05 am
by feyd
Same solution.
Posted: Sun Dec 10, 2006 3:35 am
by corillo181
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
why this dont work then?
Code: Select all
<?php
$do=fopen("sing/index.php",'w');
$write=fopen("htmlforms/join_form.html",'r');
if($do){
fwrite($do, $write);
}
fclose($do);
?>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Sun Dec 10, 2006 8:30 am
by feyd
$write isn't a string, it's a resource. You need to use
fread() or
file_get_contents()
However if you intent is to copy the file, then
copy() works far better.
Posted: Sun Dec 10, 2006 12:28 pm
by corillo181
thank you feyd