Jump to content

FTP+PHP Problem


anoopsinghal

Recommended Posts

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

<?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);
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.