mikelmao Posted June 25, 2008 Share Posted June 25, 2008 Hello, is it possible to add a page to the FTP?? But the file content has to be in the script so like: <?php Blah blah blah blah Addpage(name = site.php) { echo "<html> <body> The<br> <b>site content</b> </body> </html> ?> or somthing.. So the New page would be called site.php.. But i dont want this to go in the DB i want it to "Auto-Upload" to the Website(FTP). Is this possible?? if it is plz Type here how.. Thanks . Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/ Share on other sites More sharing options...
discomatt Posted June 25, 2008 Share Posted June 25, 2008 What? Is the script running on the same server you want to create this 'site.php' file? Check out fopen/fwrite functions Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574250 Share on other sites More sharing options...
mikelmao Posted June 25, 2008 Author Share Posted June 25, 2008 ye its on the same server Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574255 Share on other sites More sharing options...
discomatt Posted June 25, 2008 Share Posted June 25, 2008 Here's a quick example, using the above recommended functions <?php $dir = '/path/to/destination/'; $file = 'new_page.php'; if ( file_exists( $dir.$file ) ) exit( 'File already exists!' ); if ( ($h = fopen( $dir.$file, 'w' )) === FALSE ) exit( 'Could not create file!' ); $data = <<<ILOVEHEREDOC <some> <html> <content> <here> ILOVEHEREDOC; if ( !fwrite( $h, $data ) ) exit( 'Could not write to file!' ); echo 'File created successfully'; fclose( $h ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574260 Share on other sites More sharing options...
trq Posted June 25, 2008 Share Posted June 25, 2008 ye its on the same server Then its not uploading anywhere is it? you simply need to create a file. Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574262 Share on other sites More sharing options...
mikelmao Posted June 25, 2008 Author Share Posted June 25, 2008 well it 1/2 works.. But i need to add to it a php Script and that wont work.. <? $filename = 'lol.php'; $content = " <? $title = 'A titel'; $host = 'localhost'; $dbuser = 'root'; $dbpass = '******'; $db = 'database'; ?> " ; if i ad ?> The rest of the script wont work.. How do i do it .. please help thanks > and < WONT work Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574287 Share on other sites More sharing options...
trq Posted June 25, 2008 Share Posted June 25, 2008 Firstly, don't use <? use <?php. <?php $dir = '/path/to/destination/'; $file = 'new_page.php'; if ( file_exists( $dir.$file ) ) exit( 'File already exists!' ); if ( ($h = fopen( $dir.$file, 'w' )) === FALSE ) exit( 'Could not create file!' ); $data = '<?php $filename = \'lol.php\'; $content = \'\' $title = \'A titel\'; $host = \'localhost\'; $dbuser = \'root\'; $dbpass = \'******\'; $db = \'database\'; ?>'; if ( !fwrite( $h, $data ) ) exit( 'Could not write to file!' ); echo 'File created successfully'; fclose( $h ); ?> Can I ask why your creating php files on the fly? Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574290 Share on other sites More sharing options...
mikelmao Posted June 25, 2008 Author Share Posted June 25, 2008 Did u even test that script? I dont think so.. Cause thats the most ****** up script i have ever seen! Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574300 Share on other sites More sharing options...
discomatt Posted June 25, 2008 Share Posted June 25, 2008 My example is, in my opinion, more than enough to get you started. If you don't understand my code, or are unable to look up the functions in the manual and then understand it, you need to go back to the basics. Having others code for you will lead to an endless loop of problems you can't fix. Did u even test that script? I dont think so.. Cause thats the most ****** up script i have ever seen! He's trying to help... and his script is fine, it's just missing an opening quote. Insulting people that are trying to help you is not a great way to get your problem solved. Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574302 Share on other sites More sharing options...
trq Posted June 25, 2008 Share Posted June 25, 2008 Did u even test that script? I dont think so.. Cause thats the most ****** up script i have ever seen! No I didn't test the script, nor did I preview my post. It would seem the board removed alot of the quotes I put in place, trust me, I don't make such simple mistakes. You might want to mind your manners a little mate. Quote Link to comment https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574498 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.