GetDotted Domains

Viewing Thread:
"PHP ftp_put command..."

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Thu 12/08/04 at 11:24
Regular
"Pouch Ape"
Posts: 14,499

$new_file_name = "filename.jpg";

$file_a = "$form_image_a";
$remote_file = "$new_file_name";
$ftp_host = "hostname";
$conn_id = ftp_connect($ftp_host);

$ftp_user_name = "username";
$ftp_user_pass = "password";

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

if(ftp_put($conn_id, $remote_file, $file_a, FTP_BINARY))
{ print("Successfully uploaded $file_a \n"); }
else
{ print("There was a problem while uploading $file_a \n"); }

ftp_close($conn_id);

?>


What's wrong with that? Please.
Fri 13/08/04 at 20:48
Regular
"whoneedsatagline?"
Posts: 194
Try checking that the connection and login are working ... code nicked from PHP manual:

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
Thu 12/08/04 at 23:19
Regular
"Eff, you see, kay?"
Posts: 14,156
Tried specifying absolute paths or trying to acquire a more verbose error message?
Thu 12/08/04 at 21:29
Regular
"Pouch Ape"
Posts: 14,499
Yip, no problems there.
Thu 12/08/04 at 21:04
Regular
"It goes so quickly"
Posts: 4,083
Do you have the correct permissions set on the folder which accepts the files?
Thu 12/08/04 at 21:00
Regular
"It goes so quickly"
Posts: 4,083
Mode wrote:
> My knowledge of PHP is very limited.
> But shouldn't there be a ';' after:
> if(ftp_put($conn_id, $remote_file, $file_a, FTP_BINARY))';'<
> There?

Not in this case, as an if statement is being used. If you look on the next line, you'll see he's opening up the block with the {.
Thu 12/08/04 at 21:00
Regular
"Pouch Ape"
Posts: 14,499
I actually get the correct - "There was a problem while uploading $file_a \n" - error message, so the code is working to an extent. I'm pretty sure it's enabled, because it's an open server, so why would they disallow it?
Thu 12/08/04 at 20:42
Regular
"Eff, you see, kay?"
Posts: 14,156
What's the error you were getting?
Thu 12/08/04 at 16:57
Regular
Posts: 5,323
How about turning on Passive Mode?
Because the script is trying to act like a client.
Thu 12/08/04 at 16:52
Regular
Posts: 4,279
If it's anything like C++ then you dont use semi colons on if statements.
Thu 12/08/04 at 16:43
Regular
Posts: 5,323
My knowledge of PHP is very limited.
But shouldn't there be a ';' after:
if(ftp_put($conn_id, $remote_file, $file_a, FTP_BINARY))';'< There?

Probably not but my knowledge of PHP is poor.

Edit:
Oh..
Also wouldnt you have to specify the size of the file that you wish to upload?

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Thanks!
Thank you for dealing with this so promptly it's nice having a service provider that offers a good service, rare to find nowadays.
First Class!
I feel that your service on this occasion was absolutely first class - a model of excellence. After this, I hope to stay with Freeola for a long time!

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.