Jump to content

Recommended Posts

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 .

Link to comment
https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/
Share on other sites

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 );

?>

Link to comment
https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574260
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574287
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574290
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574302
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/111884-adding-a-page-to-ftp/#findComment-574498
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.