Page 1 of 1

FTP+PHP Problem

Posted: Sat Sep 16, 2006 1:32 pm
by anoopsinghal
feyd | 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]


Dear All,

I am using the following code for doing ftp upload it doesn't show up any error but the file is not uploaded.

I will be highy thankful if someone solves the problem

Code: Select all

<?php
$HOST=$_SESSION["host"];
$UN=$_SESSION["username"];
$PW=$_SESSION["password"];
$conn = ftp_connect($HOST);
if(!$conn) {
echo("Could not connect to server: $HOST\n");
}
if(!ftp_login($conn,$UN,$PW)) {
echo("Could not log in\n");
}

ftp_pasv($conn,true);
$filenew=$_POST["filenew"];
$file=$_POST["file"];

$basename= preg_replace( '/(\\\\\\\\)/', '/', $filenew);
$file='.'.$file.'/'.basename($basename);

echo("file".$file);
echo("filenew".basename($basename));

$upload = ftp_put($conn,basename($basename),$file,FTP_BINARY);

if (!$upload) { 
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
ftp_close($conn);
?>

feyd | 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: Sat Sep 16, 2006 1:44 pm
by feyd
What is $_POST['file']? After manipulating $file, is it a still a valid path?

Posted: Sun Sep 17, 2006 8:16 am
by anoopsinghal
$_POST['file']?

it is the current diretory of remote location where I am uploadng file.