Helpful Information
 
 
Category: FTP Help
ftp_put error

I'm getting this when warning when I try the use the ftp_put command. It is : ftp_put: PORT command successful. in /......../web.cls.php on line 394. Every thing was working fine until a couple of days ago when it just stopped working.
The connection seems to be opening ok, and then it hangs when trying to right the file.
Can any one point me in the right direction of what is going wrong?

ftp_put: PORT command successful. in /......../web.cls.php on line 394
so you get that echoed when try to upload file? Does the file get uploaded? Weird, PORT is sort of alternative of PASS, and the difference between two is in the way how they do listing of dirs - somewhat different methods of getting info. Both of them have not much to do with file uploading, so you'll have to show some code.

Heres the code I'm using, two days ago it was working fine:

function upload($page,$pageName)
{
//connect to remote host
if(!($this->filetp=ftp_connect($this->ftp->host)))
{
print"ftp error";
die;
}
if(!ftp_login($this->filetp,$this->ftp->login,$this->ftp->password))
{
print'login error<br>';
}

//create a temp. file
if(!$file=fopen("temp".$this->id,"w")) {
print"error creating page $pageName<br>";
die;
}

fputs($file,$page);
fclose($file);
if(!ftp_put($this->filetp,$this->ftp->path."/$pageName","temp".$this->id, FTP_ASCII)) {
print"error putting $pageName<br>";
die;
}

//delete temp file
unlink("temp".$this->id);

//close ftp connection
ftp_quit($this->filetp);
}


It creates the temp file no problems and even creates the file on the server it is uploading to. The Uploaded file is empty though

Your logic is not very clear here, but lets go step by step.
For debuging purposes let $this->id be 12. Your code does create temp12 file on hdd in the same dir as php file and file does have something in it. Then it uploads temp file to ftp, but it is empty there. By what name does it upload?

the uploaded page name is $pageName, for example index.php.

Uhm. I do see one problem in your problem. Why bother uploading files anyway? Why don't you just write $page into $pageName without using extra ftp connection? I mean, couldn't you just use fopen and fputs? That'll make things faster and easier...

That could be a better solution, I'll give it a try thanks for the help.










privacy (GDPR)