Source for file class.upload.php
Documentation is available at class.upload.php
* @author linea21 <info@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
var $IMAGE_TYPE = array("jpeg", "jpg", "png", "gif", "svg");
* Vérifie la taille d'un fichier
* @param string $file_size : taille du fichier a uploader
* @param string $max_file : taille de fichier maximale
* @return bool true si ok sinon message d'erreur (string)
include('../languages/' . U_L . '/lang_system.'. CHARSET . '.php');
if ($file_size > $max_file) {
* upload::CheckMimeImageType()
* verifie le type Mime d'une image
* @param string $dirname : chemin + nom du fichier
* @return boolean $result
if ($exif_type == 1 || $exif_type == 2 || $exif_type == 3) return true;
* upload::CheckExtImage()
* Verifie l'extension d'une image
* @param string $filename : nom du fichier
include('../languages/' . U_L . '/lang_system.'. CHARSET . '.php');
$result = $lang['upload']['CheckExtImage'];
for ($i = 0;$i < count($ext);$i++ ) {
if ($extension == $ext[$i]) return true;
* détermine l'extension d'un fichier
* @param string $filename : fichier source
* @return string $extension
$extension = $ext[count($ext)- 1];
* obtenir le nom d'un fichier, sans son extension
* @param string $filename : fichier source
while ($i < count($ext)- 1) {
$a = explode(',', MEDIA_ALLOWED_EXT);
* archive un fichier si nécessaire
$temp_path = $short_path . "/temp_" . $filename;
$shortname = $this->GetName($filename);
for($i = 0; $i < count($ext); $i++ ) {
$current_path = $short_path . "/" . $shortname . $ext[$i];
$current_old_path = $short_path . "/old_" . $shortname . $ext[$i];
$current_temp_path = $short_path . "/temp_" . $shortname . $ext[$i];
// gestion des fichiers de miniatures
* upload un fichier - Protocole HTTP
* @return boolean : Message d'erreur ou True;
include('../languages/' . U_L . '/lang_system.'. CHARSET . '.php');
if ($this->FILE['name'] != 'none' && $this->FILE['size'] != 0) {
// if file already exists we delet it first
// we create folder if needed
$result = $lang['upload']['prohibited_transfert'];
$result = "'" . $this->FINAL_NAME . "'" . $lang['upload']['file_exist_yet'];
* !!! NON IMPLEMENTE/ NON TESTE !!!
* upload un fichier - Protocole FTP
* @return boolean : Message d'erreur ou True;
include('../languages/' . U_L . '/lang_system.'. CHARSET . '.php');
if ((!$conn_id) || (!$login_result)) {
$erreur = $lang['upload']['ftp_conn_failed'] . END_LINE;
$erreur .= $lang['upload']['ftp_conn'] . ' ' . $this->FTP_SERVER . ' ' . $lang['upload']['ftp_user'] . ' : ' . FTP_USER ;
$result = $lang['upload']['ftp_transfert_error'];
* For a given image file (ie : /path/1.jpg), it will delete
* /path/1.gif, /path/1.jpeg, /path/1.png files
* @param boolean $exclude
$path = $path_parts['dirname']. '/'. $path_parts['filename'];
for($i= 0; $i < count($exts); $i++ ) {
unlink ($path. '.'. $exts[$i]);
* @param string $file : tableau contenant les caractéristiques du fichier à télécharger
* @param string $final_name : nom de sortie du fichier
* @param string $destination : répertoire de destination du fichier
* @return boolean : Message d'erreur ou True;
function UploadFile($file, $final_name, $destination)
* echo "poids maxi en ko : " . $_POST['MAX_FILE_SIZE'] . "<br>";
* echo "nom du fichier : " . $file['name'] . "<br>";
* echo "nom temp du fichier : " . $file['tmp_name'] . "<br>";
* echo "taille du fichier : " . $file['size'] . "<br>";
* echo "type du fichier : " . $file['type'] . "<br>";
* echo "ereur du fichier : " . $file['error'] . "<br>";
* echo "nom final du fichier : " . $final_name . "<br>";
* echo "destination du fichier : " . $destination . "<br>";
* echo "methode de transfert du fichier : " . $method . "<br>";
$result = $this->_FTPUpload();
$result = $this->_HTTPUpload();
$result = $this->_HTTPUpload();
|