Trying to use the Laravel-FTP plugin
Ajax:
function subir_archivo(archivo){
console.log(archivo);
$.ajax({
type: 'post',
url: 'materiales/subir',
data: {
archivo: archivo
},
}).then(
function(data) {
console.log(data);
}, function(data) {
console.log(data);
alertify.alert('Error',data);
}, function() {
console.log('this will run if the deferred generates a progress update');
}
);
}
Driver:
public function subir(Request $req) {
try{
//Direccion local del archivo que queremos subir
$fileLocal = $req->archivo;
/*Direccion remota donde queremos subir el archivo
En este caso seria a la raiz del servidor*/
$fileRemote = '/';
$mode = 'FTP_BINARY';
//Hacemos el upload
FTP::connection()->uploadFile($fileLocal,$fileRemote,$mode);
return \Response::json(array('archivo' => $fileLocal, 'ruta' => $fileRemote));
}catch(Exception $e){
return Response::json(array('Error' => $e));
}
}
I get the following error:
ErrorException in Ftp.php line 46:
ftp_connect () expects parameter 2 to be long, string given
Update 1:
?php
return array(
/*
|--------------------------------------------------------------------------
| Default FTP Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the FTP connections below you wish
| to use as your default connection for all ftp work.
|
*/
'default' => 'conexion',
/*
|--------------------------------------------------------------------------
| FTP Connections
|--------------------------------------------------------------------------
|
| Here are each of the FTP connections setup for your application.
|
*/
'connections' => array(
'conexion' => array(
'host' => 'ftp.xxx.com.ve',//probado y funcional
'port' => '',
'username' => 'xxx.com.ve',//probado y funcional
'password' => 'xxx',//probado y funcional
'passive' => false,
),
),
);