Jump to content

PHP FTP_PUT Trouble


kool_samule

Recommended Posts

Hi Chaps,

 

I've created a web-based FTP site, but having trouble with PHP's FTP_PUT function.

 

I've tried:

// FTP access parameters
$host = 'ftp.example.org';
$usr = 'example_user';
$pwd = 'example_password';

// file to move:
$local_file = './example.zip';
$ftp_path = '/data/example.zip';

// connect to FTP server (port 21)
$conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");

// send access parameters
ftp_login($conn_id, $usr, $pwd) or die("Cannot login");

// turn on passive mode transfers (some servers need this)
// ftp_pasv ($conn_id, true);

// perform file upload
$upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_BINARY);

// check upload status:
print (!$upload) ? 'Cannot upload' : 'Upload complete';
print "\n";

// close the FTP stream
ftp_close($conn_id);

 

And also Net_FTP's FTP_PUT function:

require_once 'Net/FTP.php';

  $test = new Net_FTP('www.domain.co.uk', 21);
  
  $test->connect('www.domain.co.uk', 21);
  
  $test->login('username', 'password');
  
$file_tmp = $_FILES["file"]["tmp_name"];
$file_name = $_FILES["file"]["name"];

$test->put($file_tmp, 'Uploads/'.$file_name, FTP_BINARY);

 

I've tested this with a very small text file and it works OK, but when I try with a zip file of around 9Mb it takes FOREVER, and sometimes doesn't upload at all, or if it does, it has a size of 0kb.

 

I need the script to handle big files up to 150Mb in size.

 

What can I do to speed up the process and is there something I have missed (current config settings > ini_set('max_upload_filesize', 150000000)) ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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