Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    php ftp files incompleti

    salve a tutti,
    ho creato uno script che trasferisce una intera directory da un dominio ad un altro...

    i files li trasferisce, crea le sottodirectory... ma molti files sono incompleti...

    es.. una immagine jpg di 20kbyte dopo il trasferimento è 12 byte... come può essere???

    lo stesso per i file css e php...

    pensavo che era il modo ASCII o BYNARY... ma è lo stesso...

    uso una classe_ftp.. ma il file con il codice non me lo impagina bene...

    grazie

  2. #2
    devi per lo meno postare il codice. non siamo indovini.

  3. #3
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    ...se la differenza è notevole e magari i file "corti" hanno tutti le stesse dimensioni (pochi bytes) prova a scaricare uno di questi e ad aprirlo come file di testo: potrebbe essere un contenuto non collegato a quello originale ma un qualche messaggio... aprine uno p.es. con "blocco note"...

  4. #4
    ˙Ĝ˙à JFIF    ˙ŝ ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75
    ˙Û C  
      qst è il contenuto di un file jpg...
    non so che voglia dire !!!

  5. #5
    Codice PHP:
    <?
    $vet_text 
    = array("txt""asp""html""php""htm""xml");

    if(!isset(
    $_POST['ftp_server'])){
    ?>
    <html>

    <head>
      <title></title>
    </head>

    <body>
    <CENTER>



    <font color=white>TRASFERIMENTO SITO</font>



    <form method="post" action="trasf.php" >
       <font color=white> FTP SERVER:</font> <input type="text" name="ftp_server" size=40> 


       <font color=white> FTP USERNAME:</font> <input type="text" name="ftp_username" size=35> 


       <font color=white> FTP PASSWORD:</font> <input type="password" name="ftp_pass" size=35> 


        <input type="submit" value="TRASFERISCI">
    </form>
    </CENTER>
    </body>

    </html>
    <?

    }
                           else {
     
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
    <html>
    <head>
      <title></title>
      <link href="style.css" rel="stylesheet" type="text/css" />
    </head>

    <body >
    <?php
    // VARIABILI //
    $path "../cartella";

    $ftp_server=$_POST['ftp_server'];
    $ftp_username=$_POST['ftp_username'];
    $ftp_password=$_POST['ftp_pass'];
    $destinazione="www".substr($ftp_server3)."/ftp_test1/";
    //echo $destinazione;

    //funzione stampa buffer
    function echo_flush($txt){
        
    //inizializzazione del buffer per l'output
        
    if (ob_get_level() == 0ob_start();
        echo 
    $txt;
        
    //per Chrome e Safari si deve aggiungere questa istruzione
        
    print str_pad('',4096)."\n";
        
    //invia il contenuto al buffer
        
    ob_flush();
        
    flush();
    }


    // legge i file e le directory di una cartella!!!
    function scanFileNameRecursivly($path '', &$name = array() )
    {
      
    $path $path == ''dirname(__FILE__) : $path;
      
    $lists = @scandir($path);

      if(!empty(
    $lists))
      {
          foreach(
    $lists as $f)
          {

          if(
    is_dir($path.DIRECTORY_SEPARATOR.$f) && $f != ".." && $f != ".")
          {
              
    scanFileNameRecursivly($path.DIRECTORY_SEPARATOR.$f, &$name);
          }
          else
          {   if(
    $f != "..")
              
    $name[] = $path.DIRECTORY_SEPARATOR.$f;

          }
          }
      }
      return 
    $name;
    }

    echo_flush ("<script type=\"text/javascript\">
            parent.visualizza();
                </script>"
    );


    $file_names scanFileNameRecursivly($path);

    unset( 
    $file_names[0] );    //RIMUOVO PRIMO ELEMENTO!!

    //CALCOLO PER PROGRESS-BAR
    $tot count($file_names);
    $pe $tot 10;
    $wwintval($pe);
    $incr=$ww;

    include(
    'ftp_class.php');

    $ftp = new FTPCon($ftp_server$ftp_username$ftp_password);

    if (
    $ftp->connect()) {
         
    $p=1;$q=1;
          foreach( 
    $file_names as $key => $value )
        {

          
    $val str_replace("\\""/"$value);
          
    $val_ok substr($val,13);
          if(
    substr($value, -1)=="."){
          
    //$dir = $ftp->mkdir($destinazione.$val_ok);
          
    if(!$ftp->mkdir($destinazione.$val_ok))  echo("CREAZIONE ".$destinazione.$val_ok." FALLITA!!!");
          
    $dir2 $ftp->chmod($destinazione.$val_ok0777);

          }
          else{
              
    //$upload = $ftp->upload($value, $destinazione.$val_ok); //Returns true/false
               
    $trova_punto explode("."$val_ok);
             
    $estensione $trova_punto[count($trova_punto) - 1];
             
    $estensione strtolower($estensione);
             echo 
    $estensione."
    "
    ;
             if (
    in_array($estensione$vet_text)){
            if(!
    $ftp->upload($value$destinazione.$val_ok,FTP_ASCII))  echo("TRASFERIMENTO ".$destinazione.$val_ok." FALLITO!!!");
            }
            else {

               if(!
    $ftp->upload($value$destinazione.$val_ok,FTP_BINARY))  echo("TRASFERIMENTO ".$destinazione.$val_ok." FALLITO!!!");

            }

          }

             if(
    $p == $ww) {
                 
    $te=$q*10;
                 if (
    $te==100)$te=98;
                 
    echo_flush ("<script type=\"text/javascript\">
                parent.clikke("
    .$te.");
                    </script>"
    );
                 
    $ww $ww $incr;
                 
    $q++;
                 }
         
    $p++;

        }


            
    $ftp->logout();


        }
        
    $te=100;
         
    echo_flush ("<script type=\"text/javascript\">
            parent.clikke("
    .$te.");
                </script>"
    );

    ?>

    </body>

    </html>
    <?
    }
    ?>
    ftp_class:

    Codice PHP:
    <?php
    class FTPCon {
        var 
    $host '';
        var 
    $username '';
        var 
    $password '';
        var 
    $port 21;
        var 
    $ftpcon null;

        function 
    __construct($host$username$password$port 21) {
            
    $this->host $host;
            
    $this->username $username;
            
    $this->password $password;
            
    $this->port $port;
        }

        function 
    connect() {
            if (isset(
    $this->host$this->username$this->password$this->port)) {
                
    $this->ftpcon ftp_connect($this->host$this->port);
                if (!
    $this->ftpcon) {
                    return 
    false;
                }
                if (!
    ftp_login($this->ftpcon$this->username$this->password)) {
                    return 
    false;
                }
                
    ftp_pasv ($this->ftpcontrue);
                return 
    true;
            }
        }

        function 
    ls($dir '.') {
            if (isset(
    $this->ftpcon)) {
                
    $ls ftp_nlist($this->ftpcon$dir);
                return 
    $ls;
            }
        }

        function 
    upload($file$path$mode FTP_ASCII) {
            if (isset(
    $file$path)) {
                if (
    file_exists($file)) {
                    
    $upload ftp_put($this->ftpcon$path$fileFTP_ASCII);
                    return 
    $upload;
                }
            }
            return 
    false;
        }

        function 
    download($file$path$mode FTP_BINARY) {
            if (isset(
    $file)) {
                if (
    ftp_get($this->ftpcon$path$fileFTP_BINARY)) {
                    return 
    true;
                }
            }
            return 
    false;
        }

        function 
    chmod($file$permissions 0644) {
            if (isset(
    $file)) {
                if (
    ftp_chmod($this->ftpcon$permissions$file) !== false) {
                    return 
    true;
                } else {
                    return 
    false;
                }
            }
        }

        function 
    mkdir($dirname) {
            if (isset(
    $dirname)) {
                return 
    ftp_mkdir($this->ftpcon$dirname);
            }
        }

        function 
    delete($file) {
            if (isset(
    $file)) {
                return 
    ftp_delete($this->ftpcon$file);
            }
        }

        function 
    logout() {
            if (isset(
    $this->ftpcon)) {
                
    ftp_close($this->ftpcon);
                unset(
    $this->ftpcon);
            }
        }

        function 
    __destruct() {
            
    $this->logout();
        }
    }


    ?>

  6. #6
    NEESUNA IDEA !!! ADESSO VADO IN FERIE....

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.