Page 1 of 1

ftp_put() not working

Posted: Tue Apr 11, 2006 10:40 am
by empiresolutions
Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hello all.

Im trying to ftp a .csv using ftp_put() and it is not working. Im getting an error saying that basiacally ftp_put() is returning FALSE. 
     - "There was a problem while uploading ITS_BLI_05.csv to imports.site_name.com"

My HSP says i have all the right server settings, including an updated *vhost.conf* file. below are my scripts. site_name = whatever.com. Thank for the help.

Code: Select all

/******************/
/*  VHOST.CONF   ********/
/******************/


<Directory "/var/www/vhosts/site_name/httpdocs">
php_admin_value open_basedir "/var/www/vhosts/site_name/httpdocs:/usr/share/pear:/tmp:/var/www/vhosts/site_name/httpdocs/upload:/upload"
php_admin_value safe_mode Off
</Directory>

Code: Select all

/******************/
/*  MY CODE   ********/
/******************/

	// SEND DATA TO ITS LOAD BOARD 
	// Uplaod via FTP to ITS Load Board
	// -------------------------------------------

	
	$host = "imports.site_name.com";
	$ftp_user_name = 'user_name';
	$ftp_user_pass = 'pass_word';

        // File name to be given on the $host server
	$remote_file = "ITS_BLI_05.csv";

        // file location on local server
	$file = "/upload/ITS_BLI_05.csv";

	$hostip = gethostbyname($host);
	$conn_id = ftp_connect($hostip);

	// login with username and password
	$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

	// IMPORTANT!!! turn passive mode on
	ftp_pasv ( $conn_id, true );

	if ((!$conn_id) || (!$login_result)) {

	  echo "FTP connection has failed!";
	  echo "Attempted to connect to $host for user $ftp_user_name";
	  die;

	} else {

	  /* upload a file */

	  if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {

		echo "successfully uploaded $file<br>";

	  } else {

		echo "There was a problem while uploading $file to $host<br>";

	  }
	   
	  // close the connection
	  ftp_close($conn_id);

	}


/******************/
/*  end code   ********/
/******************/
Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Apr 11, 2006 10:43 am
by Benjamin
Is it resolving the hostname properly?

Maybe try it with an IP

Posted: Tue Apr 11, 2006 10:53 am
by empiresolutions
i believe so by the error it is calling.

Posted: Tue Apr 11, 2006 10:57 am
by JayBird
This line is incorrect

Code: Select all

$file = /upload/ITS_BLI_05.csv";

Posted: Tue Apr 11, 2006 11:19 am
by empiresolutions
typo is in the forum only. script is properly quoted.

Posted: Tue Apr 11, 2006 11:23 am
by JayBird
empiresolutions wrote:typo is in the forum only. script is properly quoted.
Whats the point of posting code that doesn't match the original entirely...who knows what else may be incorrect.

Saves everyones time and effort

Posted: Tue Apr 11, 2006 11:33 am
by empiresolutions
Schooling noted Pimptastic.

Posted: Wed Apr 12, 2006 2:54 pm
by empiresolutions
any more bright ideas out there?

Posted: Thu Apr 13, 2006 2:41 pm
by empiresolutions
i fixed it. simple pathing error.

old -

$file = "/upload/ITS_BLI_0".$_POST['id'].".csv";

new -

$file = "../../upload/ITS_BLI_0".$_POST['id'].".csv";