Jump to content

php ftp


kleb

Recommended Posts

It means File Transfer Protocol and it is used instead of http (i.e. ftp://www.example.com/). It is mainly used in uploading files to sites, (like through FileZilla) but it can also be used to download from sites. I do not know HOW to use it though, but someone else should be able to tell you

Link to comment
https://forums.phpfreaks.com/topic/253848-php-ftp/#findComment-1301398
Share on other sites

you can use ftp to bypass php max file upload limit I believe (Not the only use though). You don't need to use it for download though.

 

php.net file upload:

<?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);
?>

 

php.net file download:

<?php

// define some variables
$local_file = 'local.zip';
$server_file = 'server.zip';

// 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);

// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}

// close the connection
ftp_close($conn_id);

?>

Link to comment
https://forums.phpfreaks.com/topic/253848-php-ftp/#findComment-1301403
Share on other sites

please can you teach me how to use it for both upload and download

thanks

 

As I said in your previous thread, MediaFire is sufficient for your needs. Having people download from your website will only increase your bandwidth usage, thus costing you more money. Money which wouldn't have needed to be spent in the first place. Plus, if too many people download at one time, your server will slow to a crawl.

Link to comment
https://forums.phpfreaks.com/topic/253848-php-ftp/#findComment-1301405
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.