Jump to content

ftp upload


ntesla123

Recommended Posts

I have made this script to upload to an ftp server.

How do I get the script to try to restart the upload if it fails? (if if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) returns false)

 

<?php
$file = 'file.wmv';
$remote_file = 'file.wmv';

// set up basic connection
$conn_id = ftp_connect('ftp.eu.filesonic.com');

$ftp_user_name='username';
$ftp_user_pass='password';

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}

// close the connection
ftp_close($conn_id);
?>

Link to comment
https://forums.phpfreaks.com/topic/230486-ftp-upload/
Share on other sites

looking at your code, I see that it the same as php.net.

 

If you got permission to send a file or use ftp it will happen else not.

 

A ftp problam is usally the password  or members name .

 

If you want to advance the code, maybe you need to add some ajax.

 

you code looks ok , does it work.

 

Your last else commnd stops un reg users uploding. like  below.

 

from php.net

<?php
$file = 'somefile.txt';
$remote_file = 'readme.txt';

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}

// close the connection
ftp_close($conn_id);
?>

Link to comment
https://forums.phpfreaks.com/topic/230486-ftp-upload/#findComment-1186896
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.