![]() |
[Solved]Write_file question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: [Solved]Write_file question (/showthread.php?tid=28504) |
[Solved]Write_file question - El Forum - 03-12-2010 [eluser]mrwilson1[/eluser] I have data that is being written from a form and going into a db, but I am trying to make a txt backup of it as well. All data validates, get written to the db but the data will not write to the file. The post_backups directory is under applications with the controller, models and views. Code: // field name, error message, validation rules This seems awfully simple but Im not seeing where Im going wrong. Thanks [Solved]Write_file question - El Forum - 03-12-2010 [eluser]tomcode[/eluser] You probably need to change the write permission for the folder post_backups. Also I would use the CI constant APPPATH : Code: $this->path = APPPATH ."post_backup/"; You can also add a check to verify Your path: Code: echo 'is_dir ' .(int) is_dir($this->path); [Solved]Write_file question - El Forum - 03-12-2010 [eluser]mrwilson1[/eluser] Thanks, I wondered why I was not getting any kind of an error from this. lemme try what you got. Thanks again [Solved]Write_file question - El Forum - 03-12-2010 [eluser]mrwilson1[/eluser] I get a "is dir() from the test using both the way it was and the APPATH method, the folder is 777 Is this correctly written? <code>$this->file = $this->path . $post_title . 'txt';</code> [Solved]Write_file question - El Forum - 03-12-2010 [eluser]tomcode[/eluser] Do You get 'is_dir 0' or 'is_dir 1' ? If it's 0, then the path is not correct. If it's 1, try to write a file with a different name, You use htmlspecialchars in the validation, sounds weird to me to use that for file names, try with a plain ASCII name whether that works. Quote:Is this correctly written? Yeah. I'd forget about the post stuff and just try to get the file writing part going with some fake data / filename. If that works, move on, one by one. [Solved]Write_file question - El Forum - 03-12-2010 [eluser]mrwilson1[/eluser] I get the is_dir0 so evidently the path isnt right. that must be why its not writing. I will make sure Im getting to the directory with some simple data then adjust it to the posting in the morning. Thanks ever so much, I appreciate you [Solved]Write_file question - El Forum - 03-13-2010 [eluser]mrwilson1[/eluser] I have everything fixed except for one small problem. When I try to create the filename, the $post title appends itself with the txt. From Code: $this->file = $this->path . $post_title."txt"; I get the title plus the txt. Example titletxt. What I am trying to get is obviously title.txt. How can I write the $post_title.txt to make it come out right? Solved $this->file = $this->path . $post_title.".txt"; [Solved]Write_file question - El Forum - 03-13-2010 [eluser]tomcode[/eluser] Ah sorry, I was not exact, it must be : Code: $this->file = $this->path . $post_title.".txt"; // ".txt" instead of "txt" [Solved]Write_file question - El Forum - 03-13-2010 [eluser]mrwilson1[/eluser] LOL thanks Tomcode, I figured it out about the time you posted. Thank you so much for your help. if I knew how to mark this resolved I would |