Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/11/2017, 11:22
alvaro_trewhela
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Transferir archivos a server remoto?

Lo que pretendes es algun tipo de backup?

Si tienes errores de tiempo o tamaño de ejecución usa ini_set para cerciorar que cumples los parametros dados

Código PHP:
Ver original
  1. ini_set( 'memory_limit', 'value' ); //value in Mb end with M, ex: 50M, 50mb max send
  2. ini_set('upload_max_filesize', 'value'); //equal up
  3. ini_set('post_max_size', 'value');  //equal up
  4. ini_set('max_input_time', secs);  //max time of excecution script in seconds
  5. ini_set('max_execution_time', secs); //equal up

En cuanto a enviar archivos mediante a curl usa esto:

Código PHP:
Ver original
  1. $url = "http://127.0.0.1/dir/send.php"; //target url
  2. $file = "backup.zip"; //the file
  3. $postName = "files"; //post file name in server, ex. $_FILES["files"][properities]
  4. $timeout = 100; //timeout of excecution, in secs
  5.  
  6. $cfile = new CURLFile(realpath($file));
  7. $post = array($postName => $cfile );
  8.  
  9. $ch = curl_init();
  10. curl_setopt($ch, CURLOPT_URL, $url);
  11. curl_setopt($ch, CURLOPT_POST, 1);
  12. curl_setopt($ch, CURLOPT_HEADER, 0);
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
  14. curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: multipart/form-data'));
  15. curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);  
  16. curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);  
  17. curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  18. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  19.  
  20. $result = curl_exec($ch);
  21.  
  22. if($result === false){
  23. //to do if error
  24. }
  25. else{
  26. //to do if success
  27. }  
  28.  
  29. curl_close ($ch);

Del lado del servidor usas, tu rutina, pero con $_FILES[send], donde send = $postName del código que te di

P.S: a mi me funciona si a ti no revisa las opciones de seguridad

Edito, no vi tu edición, mira mientras consigas lo que necesitas está bien, eso si asegura que la conexión a ftp sea segura, si eso esta bien, todo ok.

Saludos

Última edición por alvaro_trewhela; 03/11/2017 a las 13:18