user3298358
user3298358

Reputation: 1

php big upload via ftp

i have to trasfer file via ftp with php. The files are big (also over 500MB). So i think use php with ftp.

<?php
// connect and login to FTP server
 $ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);

$file = "localfile.txt";

// upload file
if (ftp_put($ftp_conn, "serverfile.txt", $file, FTP_ASCII))
  {
  echo "Successfully uploaded $file.";
  }
else
  {
  echo "Error uploading $file.";
  }

// close connection
ftp_close($ftp_conn);
?> 

I have to know if the timeout is considered also in ftp trasfer. If i trasfer the file via php page like upload.php with the code write, i have the execution time limit setting on the web server ?

Upvotes: 0

Views: 152

Answers (2)

Shakir El Amrani
Shakir El Amrani

Reputation: 330

You must take too many considerations before doing this operation, as mentioned below the first thing you need to check if your FTP server allows 500MB for uploads, the second thing you must set some PHP directives like post_max_size and max_upload_size, I suggest to use an FTP library to make it easier to do that, this a great one php-ftp-client that I've build.

Upvotes: 1

Anatoliy Kim
Anatoliy Kim

Reputation: 756

Enable the feature on server side, which allows resuming file uploads.

From php you might be able to call the ftp with command_line options using functions like system(), or exec().

And, yes, in php there are limits: max_upload_size, max_execution_time, max_post_size and etc. You will have to split the whole process into steps, with reloading of the page - if needed.

Upvotes: 0

Related Questions