lucie Posted October 9, 2008 Share Posted October 9, 2008 ftp_connect() doesnt working in my live server, I have php 5+ version installed, any help really very urgent Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/ Share on other sites More sharing options...
Maq Posted October 9, 2008 Share Posted October 9, 2008 Can you post the code? Do you get errors? Try this example's format: (PHP.net ftp_connect()) $ftp_server = "ftp.example.com"; // set up a connection or die $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661403 Share on other sites More sharing options...
lucie Posted October 10, 2008 Author Share Posted October 10, 2008 Thanks for the support Im using the same code from the PHP.NET, The isuse is that the server doesnt have FTP enabled, do you know how to enable it? Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661855 Share on other sites More sharing options...
Maq Posted October 10, 2008 Share Posted October 10, 2008 Sorry, I'm not sure, you may want to contact your host. Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661919 Share on other sites More sharing options...
nadeemshafi9 Posted October 10, 2008 Share Posted October 10, 2008 Thanks for the support Im using the same code from the PHP.NET, The isuse is that the server doesnt have FTP enabled, do you know how to enable it? when u log into ur control pannel u need to create an ftp account, how do u upload files you must have an ftp server installed otherwise u cant upload files, so use the ftp details u use to upload files to ur server. Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661930 Share on other sites More sharing options...
Maq Posted October 10, 2008 Share Posted October 10, 2008 Actually there's other protocols besides FTP to transfer files onto a server. Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661935 Share on other sites More sharing options...
lucie Posted October 10, 2008 Author Share Posted October 10, 2008 Can you send me the protocol code to transfer files to the FTP part from using FTP_CONNECT? Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661950 Share on other sites More sharing options...
Maq Posted October 10, 2008 Share Posted October 10, 2008 You can transfer with SSH. I'm not sure about coding it, you would have to google that. Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661957 Share on other sites More sharing options...
nadeemshafi9 Posted October 10, 2008 Share Posted October 10, 2008 function ftp(){ if($sys_local_server == $sys_live_site){ if ($image_size > 0) { //Connect $ftp_con = ftp_connect($GLOBALS['sys_ftp_server']); if(!$ftp_con) echo("Failed to establish an FTP connection."); if(!ftp_login($ftp_con, $GLOBALS['sys_ftp_user'], $GLOBALS['sys_ftp_pass'])) echo("Failed to log in to FTP server."); //chmod directory if(!ftp_site($ftp_con, "CHMOD 0777 "."/".$folder)) echo("Failed to CHMOD directory."); //ftp the file $ftp_put = ftp_put($ftp_con, $folder."/".$filename, $image_filename, FTP_BINARY); if(!$ftp_put) echo("Failed to FTP transfer file.");; //chmod the file if(!ftp_site($ftp_con, "CHMOD 0644 ".$folder."/".$filename)) echo("Failed to reCHMOD directory."); //chmod directory back if(!ftp_site($ftp_con, "CHMOD 0755 ".$folder)) echo("Failed to reCHMOD directory."); if($ftp_put) return true; else return false; } else return false; } } this code can help you determin if you can at least log in, rember youy need to define foilder pass and username, folder will start from var/ Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661961 Share on other sites More sharing options...
Maq Posted October 10, 2008 Share Posted October 10, 2008 part from using FTP_CONNECT? I think he meant not using FTP_CONNECT(). ??? Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661966 Share on other sites More sharing options...
lucie Posted October 10, 2008 Author Share Posted October 10, 2008 Yes, Im not using FTP Connect, becuase my server doesnt have FTP enabled. That's why Im looking for a code to transfer files to FTP apart from using FTP_CONNECT Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661972 Share on other sites More sharing options...
nadeemshafi9 Posted October 10, 2008 Share Posted October 10, 2008 Yes, Im not using FTP Connect, becuase my server doesnt have FTP enabled. That's why Im looking for a code to transfer files to FTP apart from using FTP_CONNECT can i ask how do you get your files onto ur server ? Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-661986 Share on other sites More sharing options...
lucie Posted October 10, 2008 Author Share Posted October 10, 2008 Im using Cute FTP client software to put the upload and download the files. But I have to allow the users to upload the files via code, thats where I got stuck, bcoz my server is not FTP enabled Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-662005 Share on other sites More sharing options...
Maq Posted October 10, 2008 Share Posted October 10, 2008 Im using Cute FTP client software to put the upload and download the files. Then it should work. Can you post you current code? Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-662008 Share on other sites More sharing options...
nadeemshafi9 Posted October 10, 2008 Share Posted October 10, 2008 log into your control panel and see if everythign to do with ftp is set Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-662013 Share on other sites More sharing options...
lucie Posted October 10, 2008 Author Share Posted October 10, 2008 I called up the server guys, and they said that the site is in shared host, so they cant enable the FTP Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-662023 Share on other sites More sharing options...
lucie Posted October 10, 2008 Author Share Posted October 10, 2008 Here is the code that Im using for FTP upload function CheckFTPConnection($user_name, $ftp_user_pass){ $conn_id = ftp_connect(""); // Login with username and password $ftp_user_name = "" $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); ftp_close($conn_id); if ((!$conn_id) || (!$login_result)) $returnError = "Error"; else $returnError = ""; // echo $returnError; return $returnError; } Quote Link to comment https://forums.phpfreaks.com/topic/127769-ftp_connect-doesnt-work/#findComment-662025 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.