protected function ajouter($id, $nom_arg, $extensions_valides = array(), $point_d_entree) { for ($i = 1; $i <= $this->nombre_champs_upload; $i++) { $fichier = $_FILES[$nom_arg . $i]['tmp_name']; $nom = $_FILES[$nom_arg . $i]['name']; if ($fichier != "") { $dot = strrpos($nom, '.'); if ($dot !== false) { $fich = substr($nom, 0, $dot); $extension = substr($nom, $dot + 1); if ($fich != "" && $extension != "" && (empty($extensions_valides) || in_array($extension, $extensions_valides))) { $obj = new $this->class(); $colonne = $this->typeobjet; $obj->{$colonne} = $id; $lastid = $obj->add(); $obj->charger($lastid); $obj->fichier = eregfic(sprintf("%s_%s", $fich, $lastid)) . "." . $extension; $obj->maj(); copy($fichier, $this->chemin_objet($obj->fichier)); ActionsModules::instance()->appel_module($point_d_entree, $obj); } } } } redirige($this->url_page_admin()); }
public function ajouter($nom_arg, $extensions_valides = array(), $point_d_entree) { for ($i = 1; $i <= $this->nombre_champs_upload; $i++) { $fichier = $_FILES[$nom_arg . $i]['tmp_name']; $nom = $_FILES[$nom_arg . $i]['name']; if ($fichier != "") { $dot = strrpos($nom, '.'); if ($dot !== false) { $fich = substr($nom, 0, $dot); $extension = substr($nom, $dot + 1); if ($fich != "" && $extension != "" && (empty($extensions) || in_array($extension, $extensions_valides))) { $obj = new $this->class(); $colonne = $this->typeobjet; $obj->{$colonne} = $this->idobjet; $query = "select max(classement) as maxClassement from {$obj->table} where {$this->typeobjet}='" . $this->idobjet . "'"; $resul = $obj->query($query); $maxClassement = $obj->get_result($resul, 0, "maxClassement"); $obj->classement = $maxClassement + 1; $lastid = $obj->add(); $obj->charger($lastid); $obj->fichier = eregfic(sprintf("%s_%s", $fich, $lastid)) . "." . $extension; $obj->maj(); copy($fichier, $this->chemin_objet($obj->fichier)); ActionsModules::instance()->appel_module($point_d_entree, $obj); } } } } }