Click to See Complete Forum and Search --> : [RESOLVED] FTP Issues


JeremyA
09-09-2008, 11:25 PM
So this is probably something simple im just blindly overlooking but any help is much appreciated.

I have a simple FTP script that uploads an installation script, i have other FTP scripts on the site that work perfectly except this one. Here is the code:


$host = ftphost;
$dir = ftpdir;
$usr = ftplogin;
$fpw = ftppw;
}
if(substr($dir, 0, 1)!='/'){
$dir = '/'.$dir; }
if(substr($dir, -1, 1)!='/'){
$dir = $dir.'/'; }
set_time_limit(120);

$conn = ftp_connect($host);
if(!$conn)
{ftp_quit($conn); header('Location: ../adse.php?se=2'); die(); }

$auth = ftp_login($conn, $usr, $fpw);
if(!$auth){ftp_quit($conn); header('Location: ../adse.php?se=2'); die(); }

ftp_put($conn, $dir."adm/modules/updater.php","../../PBRes/updater.php",FTP_ASCII);
ftp_site($conn,"chmod 777 ".$dir."adm/modules/updater.php");
ftp_close($conn);

it gives me no errors (other than the chmod being unsuccessful due to no file there).

Thanks,
Jeremy

Phill Pafford
09-10-2008, 07:39 AM
Hmm, need to see more code please, for the most part this looks good to me.


// Whats before this ?

$host = ftphost;
$dir = ftpdir;
$usr = ftplogin;
$fpw = ftppw;
}

if(substr($dir, 0, 1)!='/')
{
$dir = '/'.$dir;
}
if(substr($dir, -1, 1)!='/')
{
$dir = $dir.'/';
}

set_time_limit(120);
$conn = ftp_connect($host);

if(!$conn)
{
ftp_quit($conn); // If no conn why r u calling this?
header('Location: ../adse.php?se=2');
die(); // If the above redirect works this will not get called.
}

$auth = ftp_login($conn, $usr, $fpw);

if(!$auth)
{
ftp_quit($conn);
header('Location: ../adse.php?se=2');
die();
}

ftp_put($conn, $dir."adm/modules/updater.php","../../PBRes/updater.php",FTP_ASCII);
ftp_site($conn,"chmod 777 ".$dir."adm/modules/updater.php");
ftp_close($conn);

JeremyA
09-10-2008, 09:39 AM
The only thing before that is:
if($_POST['stage']==1){
Which i have taken out the if clause and tested it that way. Are there some issues with backing out of directories like i am for the source file? Im stumped.

Phill Pafford
09-10-2008, 10:06 AM
hmm, maybe try the full path instead of ../

JeremyA
09-10-2008, 05:19 PM
Grrr.
Nothing.
I also tried FTP'ing a different file and still was nothing different.

JeremyA
09-10-2008, 05:23 PM
Scratch that...
the file did go up, i forgot to change the ftp_site() file as well so that errored...okay so the moral of the story is, no backing out of directories? odd.

Well thank you for your time Phill.

Regards,
Jeremy A.