ukweb Posted August 14, 2009 Share Posted August 14, 2009 I've made a script which successfully checks to see if there is an update available, and this portion is supposed to upload the updated file to the remote site's server, but it wont work... heres my code: // Perform the update if ($_GET['a'] == 'update') { $ftp_stream = ftp_connect('sjwright.co.uk'); $row_current_site['url']; $ftp_domain = str_replace('http://', '', $row_current_site['url']); $ftp_domain = str_replace('www.', '', $ftp_domain); $ftp_domain = str_replace('/', '', $ftp_domain); $ftp_file = 'updates/framework/'.$_GET['file'].'.php'; $ftp_fp = fopen("ftp://".$ftp_username.":".$ftp_password."@sjwright.co.uk/domains/edit.sjwright.co.uk/html/".$ftp_file,"w"); $ftp_path = 'domains/'.$ftp_domain.'/html/site_editor/frameworks'; //Login to the FTP server $ftp_login = ftp_login($ftp_stream, $username_ftp, $password_ftp); if ($ftp_login) { //We are now connected to FTP server. if (@ftp_chdir($ftp_stream, $ftp_path)) { $temp = tmpfile(); if (ftp_fput($ftp_stream, $ftp_fp, $temp, FTP_ASCII)) { $notice = notice('success', 'The update was installed correctly. <a href="?app=dashboard&reset=true">Click here</a> to restart your sites files'); } else { $notice = notice('error', 'The update did not complete'); } } else { $notice = notice('error', 'There was a problem setting the core file directory'); } } //Close FTP connection ftp_close($ftp_stream); } the error I get is: Warning: fopen(ftp://[email protected]/domains/edit.sjwright.co.uk/html/updates/framework/core.php) [function.fopen]: failed to open stream: Operation now in progress in /nfs/c02/h08/mnt/26403/domains/edit.sjwright.co.uk/html/framework.php on line 3575 Warning: ftp_fput() [function.ftp-fput]: No file name in /nfs/c02/h08/mnt/26403/domains/edit.sjwright.co.uk/html/framework.php on line 3586 its really frustrating, I've spent hours on this now to no avail. ANY IDEAS ANYONE?!?!?! Thanks Ste x Link to comment https://forums.phpfreaks.com/topic/170266-pulling-my-hair-out-here-php-ftp-functions/ Share on other sites More sharing options...
Adam Posted August 14, 2009 Share Posted August 14, 2009 What's this doing? $row_current_site['url']; Edit: Scratch that idea! Obviously the problem lies with: $ftp_fp = fopen("ftp://".$ftp_username.":".$ftp_password."@sjwright.co.uk/domains/edit.sjwright.co.uk/html/".$ftp_file,"w"); Have you tried echo'in out that string on it's own? Link to comment https://forums.phpfreaks.com/topic/170266-pulling-my-hair-out-here-php-ftp-functions/#findComment-898188 Share on other sites More sharing options...
ukweb Posted August 15, 2009 Author Share Posted August 15, 2009 What's this doing? $row_current_site['url']; Edit: Scratch that idea! Obviously the problem lies with: $ftp_fp = fopen("ftp://".$ftp_username.":".$ftp_password."@sjwright.co.uk/domains/edit.sjwright.co.uk/html/".$ftp_file,"w"); Have you tried echo'in out that string on it's own? Hi I had a slight variable name blunder, but now I'm getting this: Warning: fopen(ftp://[email protected]:[email protected]/domains/edit.sjwright.co.uk/html/updates/framework/core.php) [function.fopen]: failed to open stream: Remote file already exists and overwrite context option not specified<br /> FTP server reports 213 25465 in /nfs/c02/h08/mnt/26403/domains/edit.sjwright.co.uk/html/framework.php on line 3575 Warning: ftp_fput() [function.ftp-fput]: No file name in /nfs/c02/h08/mnt/26403/domains/edit.sjwright.co.uk/html/framework.php on line 3586 AAAGGGHHH!!!! I cant find anything helpful on the internet! line 3575 is as follows: $ftp_fp = fopen("ftp://".$username_ftp.":".$password_ftp."@sjwright.co.uk/domains/edit.sjwright.co.uk/html/".$ftp_file,"w"); I will be glad to get this done, its really p*****g me off now! Link to comment https://forums.phpfreaks.com/topic/170266-pulling-my-hair-out-here-php-ftp-functions/#findComment-898878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.