Tema: Subir Imagen
Ver Mensaje Individual
  #18 (permalink)  
Antiguo 16/02/2008, 23:43
Avatar de elfran222
elfran222
 
Fecha de Ingreso: junio-2006
Mensajes: 550
Antigüedad: 17 años, 10 meses
Puntos: 7
Re: Subir Imagen

Continuación class.upload.php
Código:
        $this->forbidden = array();
        $this->allowed = array("application/rar",
                               "application/x-rar-compressed",
                               "application/arj",
                               "application/excel",
                               "application/gnutar",
                               "application/octet-stream",
                               "application/pdf",
                               "application/powerpoint",
                               "application/postscript",
                               "application/plain",
                               "application/rtf",
                               "application/vocaltec-media-file",
                               "application/wordperfect",
                               "application/x-bzip",
                               "application/x-bzip2",
                               "application/x-compressed",
                               "application/x-excel",
                               "application/x-gzip",
                               "application/x-latex",
                               "application/x-midi",
                               "application/x-msexcel",
                               "application/x-rtf",
                               "application/x-sit",
                               "application/x-stuffit",
                               "application/x-shockwave-flash",
                               "application/x-troff-msvideo",
                               "application/x-zip-compressed",
                               "application/xml",
                               "application/zip",
                               "application/msword",
                               "application/mspowerpoint",
                               "application/vnd.ms-excel",
                               "application/vnd.ms-powerpoint",
                               "application/vnd.ms-word",
                               "application/vnd.ms-word.document.macroEnabled.12",
                               "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                               "application/vnd.ms-word.template.macroEnabled.12",
                               "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
                               "application/vnd.ms-powerpoint.template.macroEnabled.12",
                               "application/vnd.openxmlformats-officedocument.presentationml.template",
                               "application/vnd.ms-powerpoint.addin.macroEnabled.12",
                               "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
                               "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
                               "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
                               "application/vnd.openxmlformats-officedocument.presentationml.presentation",
                               "application/vnd.ms-excel.addin.macroEnabled.12",
                               "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
                               "application/vnd.ms-excel.sheet.macroEnabled.12",
                               "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                               "application/vnd.ms-excel.template.macroEnabled.12",
                               "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
                               "audio/*",
                               "image/*",
                               "video/*",
                               "multipart/x-zip",
                               "multipart/x-gzip",
                               "text/richtext",
                               "text/plain",
                               "text/xml");

    }

    /**
     * Constructor. Checks if the file has been uploaded
     *
     * The constructor takes $_FILES['form_field'] array as argument
     * where form_field is the form field name
     *
     * The constructor will check if the file has been uploaded in its temporary location, and
     * accordingly will set {@link uploaded} (and {@link error} is an error occurred)
     *
     * If the file has been uploaded, the constructor will populate all the variables holding the upload 
     * information (none of the processing class variables are used here).
     * You can have access to information about the file (name, size, MIME type...).
     *
     *
     * Alternatively, you can set the first argument to be a local filename (string)
     * This allows processing of a local file, as if the file was uploaded
     *
     * The optional second argument allows you to set the language for the error messages
     *
     * @access private
     * @param  array  $file $_FILES['form_field']
     *    or   string $file Local filename
     * @param  string $lang Optional language code
     */
    function upload($file, $lang = 'en_GB') {

        $this->file_src_name      = '';
        $this->file_src_name_body = '';
        $this->file_src_name_ext  = '';
        $this->file_src_mime      = '';
        $this->file_src_size      = '';
        $this->file_src_error     = '';
        $this->file_src_pathname  = '';
        $this->file_src_temp      = '';

        $this->file_dst_path      = '';
        $this->file_dst_name      = '';
        $this->file_dst_name_body = '';
        $this->file_dst_name_ext  = '';
        $this->file_dst_pathname  = '';

        $this->image_src_x        = null;
        $this->image_src_y        = null;
        $this->image_src_bits     = null;
        $this->image_src_type     = null;
        $this->image_src_pixels   = null;
        $this->image_dst_x        = 0;
        $this->image_dst_y        = 0;

        $this->uploaded           = true;
        $this->no_upload_check    = false;
        $this->processed          = true;
        $this->error              = '';
        $this->log                = '';        
        $this->allowed            = array();
        $this->forbidden          = array();
        $this->file_is_image      = false;
        $this->init();
        $info                     = null;
        
        // sets default language
        $this->translation        = array();
        $this->translation['file_error']                  = 'File error. Please try again.';
        $this->translation['local_file_missing']          = 'Local file doesn\'t exist.';
        $this->translation['local_file_not_readable']     = 'Local file is not readable.';
        $this->translation['uploaded_too_big_ini']        = 'File upload error (the uploaded file exceeds the upload_max_filesize directive in php.ini).';
        $this->translation['uploaded_too_big_html']       = 'File upload error (the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form).';
        $this->translation['uploaded_partial']            = 'File upload error (the uploaded file was only partially uploaded).';
        $this->translation['uploaded_missing']            = 'File upload error (no file was uploaded).';
        $this->translation['uploaded_unknown']            = 'File upload error (unknown error code).';
        $this->translation['try_again']                   = 'File upload error. Please try again.';