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

    Upload via FTP e dimensione file

    Ciao a tutti,
    ho uno script che tramite le funzioni FTP mi carica online un file .zip

    Finchè si tratta di file di 4-5 MB non c'è problema, ma se provo a mettere su un file + pesante (20mb) mi da errore e non mette su un bel niente..
    Utilizzo una ADSL a 1,2 mb..

    Sto utilizzando l'ottima classe WEB3FTP scaricata da phpclasses.org

    Codice PHP:
    <?php
    /*
    =============== WEB3FTP =============
    Copyright Angelo Gelmi - 2004

    Example 1:
    Upload a file kept in your server filesystem to an another server

    include "w3k.ftmp.php";
    $ftpconnection = new web3ftp("hostofanotherserver","username","password");
    $ftpconnection->upload("./filename.ext","/remotedirectory/filename");
    $ftpconnection->close;

    Example 2:
    Upload a file kept in /tmp by a form upload (if your server avoid set permission 777 onto a directory) 
    to a directory on the same server.

    include "w3k.ftmp.php";
    $ftpconnection = new web3ftp("localhost","username","password");
    $ftpconnection->upload($_FILES["the_file"]["tmp_name"],"img/novita/".$_FILES["the_file"]["name"]);
    $ftpconnection->close;

    */

    class web3ftp {
            
        var 
    $verbose;
        function 
    web3ftp($ftp_server,$ftp_user,$ftp_password){
            
    $this->ftp_server=$ftp_server;
            
    $this->ftp_user=$ftp_user;
            
    $this->ftp_password=$ftp_password;
            
            
    $this->max_size=500000;
            
    $this->connection($this->ftp_server,$this->ftp_user,$this->ftp_password);
            
    $this->allowed = array ("image/jpeg","image/gif","image/png","image/psd");
            
            
    //$this->verbose=1;
        
    }
        
        
    //===================================
        // Make connection to server
        //===================================
        
    function connection(){
            
    //print $this->ftp_user.",".$this->ftp_password."
    ";
            
    $this->conn_id = ftp_connect($this->ftp_server); 
            
    $login_result = ftp_login($this->conn_id$this->ftp_user$this->ftp_password); 
                
            if ((
    $this->conn_id==false) || ($login_result==false)) { 
                echo "
    FTP connection aborted!";
                echo "
    Connection to $this->ftp_server for user $this->user failed!"; 
                die; 
            } else {
                if (
    $this->verbose==true)
                    echo "
    Connected at $this->ftp_serveruser $this->ftp_user";
            }
        }
        
        //===================================
        // Upload File (localfile,remotefile)
        //===================================
        function upload(
    $source_file,$destination_file){
        
            // if file name not specified alert and exit
            // otherwise make the upload
            if ((!isset(
    $source_file))||(!isset($destination_file))){
               echo "
    Some mandatory file not specified!
    ";
               echo "
    Verify origin_file and destination_file.";     
            } else {
                
    $upload = ftp_put ($this->conn_id$destination_file$source_file, FTP_BINARY);
                // controllo dello stato di upload
                if (
    $upload==false) { 
                    echo "
    FTP Loading didn't succeded - SOURCE $source_file";
                } else {
                    //$this->changePermission($destination_file,744);
                    if ($this->verbose==true)
                         echo "
    Correctly loaded file $source_file on $this->ftp_server as $destination_file";
                }
            }        
        }
        
        //===================================
        // Delete File (remotefile)
        //===================================
        function delete($destination){
            
            if (isset($destination)){
                if (@ftp_delete ( $this->conn_id, $destination)){
                    if ($this->verbose==true)
                        echo "Removed $destination at $this->ftp_server";
                }else{
                    //Errors
                    if ($this->verbose==true)
                        echo "Some errors occourred during removing: 
    ".$destination;
                }
            }            
        }
        
        //===================================
        // Change Permission To File (remotefile,permission)
        //===================================
        function changePermission($file,$permission){
            if (isset($file) && isset($permission))
                return ftp_chmod ($this->conn_id,$permission,$file);
        }
        
        
        //===================================
        // Verify parameters (weigth,mime )
        //===================================
        function checkparam($inputname){
            
            $lock="";
            if($_FILES[$inputname]['
    size']>$this->max_size){
                $this->err = "La dimensione eccede quella massima consentita ($this->max_size byte)";
                return 1;
            }
            
            // Parsa i mime consentiti
            if (!in_array ($_FILES[$inputname]['
    type'], $this->allowed)){
                    if ($this->verbose==true){
                        $this->err = "Il tipo di immagine non &egrave; tra quelli consentiti
    ";
                        $this->err .= $_FILES[$inputname]['
    type']."( ";
                        foreach ($this->allowed as $permitted)
                            $this->err.= "[b]".$permitted."[/b], "; 
                        $this->err .= ") ";
                        return 2; 
                    }    
            }
            return 0;    
        }
        
        //===================================
        // Close connection
        //===================================
        function close(){
            ftp_quit($this->conn_id); 
        }
    }


    ?>

    Questo è il mio script:
    Codice PHP:
    $ftpconnection = new web3ftp("localhost","user","psw");

    if(!
    is_file($path_dir."/".$cliente."/".$dir_name."/".$_FILES['source_file']['name'])){

    $ftpconnection->upload($_FILES["source_file"]["tmp_name"],"public/area_clienti/".$cliente."/".$dir_name."/".$_FILES["source_file"]["name"]);

    $ftpconnection->close;

    //etc etc 
    C'è forse qualche funzione x settare il tempo di esecuzione dei files??

    Stega
    :-)

  2. #2
    Utente di HTML.it L'avatar di ade_v
    Registrato dal
    Jan 2001
    Messaggi
    459
    set_time_limit(int)

    dove int è il numero di secondi
    ade_v@yahoo.it

    Fletto i muscoli e sono nel vuoto

    Se inviate messaggi privati, avvisatemi sul forum...

  3. #3
    Grazie..

    Ma non credo che il mio sia un problema di esecuzione dello script..
    Oggi ho scritto il msg un po" di fretta e non mi sono spiegato bene del tutto..

    Lo script non va in crash x via del tempo di esecuzione ma da un errore del tipo 'file di origine non trovato'..


    Some mandatory file not specified!
    Verify origin_file and destination_file


    Guardando la classe:


    Codice PHP:
    function upload($source_file,$destination_file){
        
            
    // if file name not specified alert and exit
            // otherwise make the upload
            
    if  ((!isset($source_file))||(!isset($destin
    ation_file
    ))){
               echo 
    "Some mandatory file not specified!
    "
    ;
               echo 
    "Verify origin_file and destination_file.";    
            } else {
                
    $upload ftp_put ($this->conn_id$destination_file$source_fileFTP_BINARY);
                
    // controllo dello stato di upload
                
    if ($upload==false) { 
                    echo 
    "
    FTP Loading didn't succeded - SOURCE 
    $source_file";
                } else {
                    
    //$this-> changePermission($destination_file,744);

                    
    if ($this->verbose==true)
                         echo 
    "
    Correctly loaded file 
    $source_file on $this->ftp_server as $destination_file";
                }
            }        
        } 

    Sul server upload_max_filesize è impostato a 20mb, ma questo parametro vale anche x gli upload con le funzioni di FTP??

    Cmq ho provato un file di 15 mb ed ho ottenuto lo stesso errore..


    Stega
    :-)

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.