View Full Version : ftp_put() problems
07-20-2005, 06:18 PM
Hello, I posted this on a couple of forums (one of them 15 days ago) and I still have no answers. I have tried a few things. I know this might be a little unorthadox but instead of bogging this forum post down with copy and pasting of my other posts I will just link to my post in the other forum in hopes that someone here will take a look at it.
Thank you for your time and any help with this
My post on another forum (http://www.phpbuilder.com/board/showthread.php?t=10303794&page=1&pp=15)
08-02-2005, 06:17 PM
Hopefully you will read this one.
OK, I am still having this problem but I narrowed down the issue I think.
1. I am uploading the module to the webserver.
2. Then in the next step want to ftp same module to backup server.
So I am calling
$path = "../modules";
if (!move_uploaded_file($_FILES['srcfile']['tmp_name'], $path."/".strtolower(trim($_FILES['srcfile']['name']))))
Which works. THis uploads the module to the webserver to the set location
then I call
$ftp = ftp_connect('server goes here');
// login with username and password
if (ftp_login($ftp, 'username', 'password'))
ftp_pasv ( $ftp, true );
if (ftp_put($ftp, "public_html/temp/" . $_FILES['srcfile']['name'], $_FILES['srcfile']['tmp_name'], FTP_BINARY))
$message = "File uploaded";
die("Could not upload file");
die("Could not login to FTP account");
// close the FTP stream
The only way this second FTP code works is if I comment out the first upload code,
$path = "../modules";
//if (!move_uploaded_file($_FILES['srcfile']['tmp_name'], $path."/".strtolower(trim($_FILES['srcfile']['name']))))
Can anyone tell me if the problem is a ftp stream being left open and that is why I can not get the second portion of my code to work? Is there a way to get both of these to work together? I need not only to be able to upload to the webserver but ftp a backup copy to the remote server as well.
Thank you for any help.
08-03-2005, 08:42 PM
This problem was solved for me on another forum
You used move_uploaded_file() to move the file to $path.
Originally Posted by php manual.move_uploaded_file
If the file is valid, it will be moved to the filename given by destination
The file is no longer in temp.
try ftp_put($ftp, $path)
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.