Jump to content

PHP FTP Functions - Write to a file


Disturbed One

Recommended Posts

Hello,

 

I am trying to make a function where I use PHP's ftp command to grab the contents of a file, and write to that file replaced values.

 

I have the function down that grabs the code and replaces the values, but I don't know how to write the new code back to that file.

 

Ie.

The code to be inserted in the file is:

$data = "
<strong>Value has been replaced!</strong><br />
Congratulations!
";

 

Here is what I am attempting:

		if(!ftp_fput($con, getcwd().'/index.html', $data, FTP_ASCII))
		{
			echo "There was a problem while uploading ".getcwd()."/index.html\n";
		}

But that gives me this error: Warning: ftp_fput() expects parameter 3 to be resource, array given in /home/*protected*/public_html/admin/includes/classes/class.user.php on line 985

 

Any help would be appreciated!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/64911-php-ftp-functions-write-to-a-file/
Share on other sites

Parameter 3 needs to be a file handle. Something which is created by functions like fopen().

 

In that case, I need to rewrite some code.

 

How would I

1. open a file

2. find %%HEADER%% and replace it with <h1>Username</h1>

3. save the file

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.