developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #1005: 1005-jForms-upload-mimetype-on-server-side.diff

File 1005-jForms-upload-mimetype-on-server-side.diff, 1.7 KB (added by Julien, 11 years ago)
  • lib/jelix/forms/controls/jFormsControlUpload.class.php

    diff -r b4ca6d25d1ea lib/jelix/forms/controls/jFormsControlUpload.class.php
    a b  
    33* @package     jelix
    44* @subpackage  forms
    55* @author      Laurent Jouanneau
    6 * @contributor
     6* @contributor Julien Issler
    77* @copyright   2006-2008 Laurent Jouanneau
     8* @copyright   2009 Julien Issler
    89* @link        http://www.jelix.org
    910* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
    1011*/
     
    3839                return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID;
    3940
    4041            if(count($this->mimetype)){
    41                 if($this->fileInfo['type']==''){
    42                     $this->fileInfo['type'] = mime_content_type($this->fileInfo['tmp_name']);
    43                 }
     42                $this->fileInfo['type'] = jFile::getMimeType($this->fileInfo['tmp_name']);
     43
    4444                if(!in_array($this->fileInfo['type'], $this->mimetype))
    4545                    return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID;
    4646            }
  • lib/jelix/utils/jFile.class.php

    diff -r b4ca6d25d1ea lib/jelix/utils/jFile.class.php
    a b  
    126126            rmdir($path);
    127127        }
    128128    }
     129
     130    /**
     131     * get the MIME Type of a file
     132     *
     133     * @param string $file The full path of the file
     134     * @return string the MIME type of the file
     135     * @since 1.2
     136     */
     137    public static function getMimeType($file){
     138        return mime_content_type($file);
     139    }
    129140}
    130141