Disturbed One Posted August 14, 2007 Share Posted August 14, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/64911-php-ftp-functions-write-to-a-file/ Share on other sites More sharing options...
Daniel0 Posted August 14, 2007 Share Posted August 14, 2007 Parameter 3 needs to be a file handle. Something which is created by functions like fopen(). Quote Link to comment https://forums.phpfreaks.com/topic/64911-php-ftp-functions-write-to-a-file/#findComment-323906 Share on other sites More sharing options...
Disturbed One Posted August 14, 2007 Author Share Posted August 14, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/64911-php-ftp-functions-write-to-a-file/#findComment-323907 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.