Visualizzazione dei risultati da 1 a 3 su 3

Discussione: classi??

  1. #1

    classi??

    sentite delle classi non capisco niente...e quindi della pillola su upload+resize... non ho capito niente, qualcuno sa dirmi come si include una classe e cosa è questo errore?

    Fatal error: Cannot instantiate non-existent class: imageresized in d:\documenti\uni\2sem-3anno\basi di dati\heck\album_foto\pages\upload_1.php on line 107


    Fatal error: Call to undefined function: imagecreatefromjpeg() in d:\documenti\uni\2sem-3anno\basi di dati\heck\album_foto\pages\upload_1.php(143) : eval()'d code on line 1


    e poi... perchè al posto di eseguire il codice della classe me lo printa? non c'è nessun comando che gli dice di farlo.

    ecco il contenuto della classe:
    Codice PHP:
    class ImageResized {

        
    /**
        * vars used to manage operations
        */
        
    var $type$img$size$dest$name;

        
    /**
        * public constructor
        *    ImageResized( $imageToCopyResized, $newSize [, $destinationFolderToCreateResizedImage ] );
        */
        
    function ImageResized$img$size$dest '' ) {
            
    $this->img = &$img;
            if( 
    file_exists$this->img ) == true ) {
                
    $this->type = &UcFirststrToLower$this->__file_extension$this->img ) ) );
                
    $this->name = &substr$this->img0, -( strLen$this->type ) + ) );
                if( 
    $this->type == 'Jpg' ) {
                    
    $this->type 'Jpeg';
                }
                
    $this->size = &intVal$size );
                
    $this->dest = &str_replace'//''/'$dest.'/' );
                
    $this->__createImage();
            }
        }

        
    /**
        * private method, called from constructor
        *     Check size to mantain aspect ratio, verify image type and show or create new resized image
        * @param    none    no params need
        * @return    none    headers with new image / create new image
        */
        
    function __createImage() {
                
    $imgSize getimagesize$this->img );
            
    $imgX $imgSize[0];
            
    $imgY $imgSize[1];
            
    $newY floor( ( $imgSize[1] * $this->size ) / $imgSize[0] );
            eval( 
    "\$img_original = imageCreateFrom{$this->type}( \"{$this->img}\" );" );
            
    $img_final imageCreateTrueColor$this->size$newY );
            
    imageCopyResampled$img_final$img_original0000$this->size$newY$imgX$imgY );
            if( 
    $this->dest != '/' && is_Dir$this->dest ) ) {
                eval( 
    "image{$this->type}( \$img_final, '{$this->dest}{$this->name}.".strToLower$this->type )."', 100 );" );
            }
            else {
                
    header"Content-type: image/{$this->type});
                eval( 
    "image{$this->type}( \$img_final );" );
            }
            
    imageDestroy$img_original );
            
    imageDestroy$img_final );
        }

        
    /**
        * private method, called from constructor 

  2. #2
    il codice php va incluso tra

    <?php

    e


    ?>

    altrimenti non viene interpretato


    il codice poi deve essere richiamato da un' altro file php con

    require 'nomeFileClasse.php';


    a quel punto usi la classe seguendo gli esempi scritti nei commenti della classe che sei pregato di rimettere ... visto che la classe non e' tua.


    Fatto questo , o anche prima, assicurati che il tuo spazio web o la tua configurazione supporti le librerie GD, in particolar modo le GD2
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

  3. #3
    hai ragione, scusa. lo faccio subito.

    puoi dirmi perchè hai messo:

    $img = &new ImageResized( $file,
    $newSize, $myDir );// will create it with new size

    mentre nella clsse:

    function ImageResized( $img, $size, $dest = '' ) {
    ...

    ho provato ma non funziona: non carica il file xò non da errori, anzi... non da nessuna risposta.

    ps: se io metto

    $file = $_FILES['userfile']['name'];

    è giusto?

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.