Trouble creating files php -


i tried ways know:

<?php    domdocument::savehtmlfile($filename); ?> 

,

<?php      fopen(); //i tried options , modes.     fwrite();     fclose(); ?> 

and

<?php    file_put_contents($filename, $data); ?> 

what disquiets me 3 ways returns me written bytes, if file had been created, when search file, not exists.

have idea?

actual codes:

-fopen attempt:

<?php$    $filename = $_server['document_root'] . '/view/pages/' . $pagename . '.html';    file = fopen($filename, 'x');    $save = fwrite($file, $this->topicdata['html']);    fclose($file);    if($save) return 1;    else return "error"; ?> 

-savehtmlfile attempt:

<?php    $filename = $_server['document_root'] . '/view/pages/' . $pagename . '.html';    $doc = new domdocument();    $doc->loadhtml($this->topicdata['html']);    if ($doc->savehtmlfile($filename)) return 1;    else return "error"; ?> 

-file_put_contents attempt:

<?php    $filename = $_server['document_root'] . '/view/pages/' . $newpage . '.html';    if(file_put_contents($filename, $this->topicdata['html'])) return 1;    else return 'error'; ?> 

all of them returns 1, no file created.

thank all.

the problem in part of code treats name of file created. so, overwriting files , wasn't able find file name searching by.

but thank all, it's solved.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -