I need to send files over 2GB, and I ended up reading that it is better to use FTP, I researched a bit and got this code:
uploadFTP.php
<?php
set_time_limit(0);
$server_ftp = 'xx.xx.xxx.xxx';
$usuario_ftp = SQL_USUARIO;
$senha_ftp = SQL_SENHA;
$limitar_tamanho = 0;
$arquivo = $_FILES['arquivo'];
$nome_arquivo = $arquivo['name'];
$tamanho_arquivo = $arquivo['size'];
$arquivo_temp = $arquivo['tmp_name'];
$destino = DIR_ARQUIVOS.$nome_arquivo;
$conn_ftp = ftp_connect($server_ftp);
$login_ftp = @ftp_login($conn_ftp, $usuario_ftp, $senha_ftp);
if (!$login_ftp){exit('Usuário ou senha FTP incorretos.');}
if (@ftp_put($conn_ftp, $destino, $arquivo_temp, FTP_BINARY))
{
echo 'Arquivo enviado com sucesso!';
} else {echo 'Erro ao enviar arquivo!'; }
// Fecha a conexão FTP
ftp_close( $conn_ftp );
The problem is that in my case, I have a form ( POST
) with a <input type="file">
that I use if(isset($_POST['fileInputName']))
in this way to move ( move_uploaded_file
) the file that was uploaded, however I would like of a way to do this upload (of several files in the same input) by the FTP code above, and still be able to use isset
.