problem uploading file with ftp_put ()

2

when using function ftp_put() of php to upload file to an ftp, it actually uploads the file, but it arrives without weight, that is 0 B, I attach the code that I am using (it is not problem of permissions of the folder where I'm sending it, the file comes from a form and I pick it up in the php)

$c = ftp_connect('miftp.com') or die("error al conectar");
ftp_login($c, 'miuser', 'pass') or die("no logueo");
$fichero = fopen($_FILES['sArchivo']['name'];

$remote = "/carpeta/".$_FILES['sArchivo']['name'];
ftp_put($c, $remote, $fichero ,  FTP_bynary) or die("Can't transfer");

this is the form:

<form action="../ajax/producto-checkfile.php" method="post" enctype="multipart/form-data">
    <div>   
        <label for="upload">Selecciona un fichero</label>
        <input name="sArchivo" type="file" />
        <input type="submit" name="submit" value="Enviar" />    
   </div>   
</form>
    
asked by user7649760 03.03.2017 в 14:22
source

1 answer

1

By mistake I omitted the function ftp_pasv() , I placed it true because the data connections are initiated by the client, and that's it.

    
answered by 03.03.2017 в 22:52