Index du Forum » » SFORM

Auteur

Sform avec upload ?
developpeur
24581       
 

  Posté : 05-11-2003 22:06

// Manage the

switch($pok) {

case 'Soumettre votre demande':
$m->make_response();

// Chargement de la photo
!include!_once("modules/upload/upload.conf.php");
global $avatar_size;
if (!$avatar_size) {$avatar_size="80*100";}
$avatar_limit=explode("*",$avatar_size);

// On récupère le nom et le prénom du membre dans SFORM
$uname=str_replace("","",$m->answer[$m->interro_fields("nom")]);
$uname=str_replace("
","",$uname);
$uname=str_replace("","",$uname);
$uname=str_replace("
","",$uname);
$uname=trim($uname);

if ($DOCUMENTROOT!="") {
$rep=$DOCUMENTROOT;
} else {
global $DOCUMENT_ROOT;
if ($DOCUMENT_ROOT) {
$rep=$DOCUMENT_ROOT;
} else {
$rep=$_SERVER['DOCUMENT_ROOT'];
}
}
if ($B1!="none") {
global $language;
!include!_once("modules/upload/upload.lang-$language.php");
!include!_once("modules/upload/clsUpload.php");

$upload = new Upload();
$upload->maxupload_size=$MAX_FILE_SIZE;
$field1_filename = trim($upload->getFileName("B1"));
$suffix = strtoLower(substr(strrchr($field1_filename,'.'),1));
if (($suffix=="gif") or ($suffix=="jpg") or ($suffix=="png")) {
$field1_filename=removeHack(eregi_replace ("[/\\\\:\*\?\"<>|']", "", rawurldecode($field1_filename)));
$field1_filename=eregi_replace("/etc","",$field1_filename);
$field1_filename=eregi_replace("\.\.","",$field1_filename);
$field1_filename=eregi_replace("config.php","",$field1_filename);
if ($field1_filename) {
if ($autorise_upload_p) {
$user_dir=$racine."/users_private/".$uname."/";
if (!is_dir($rep.$user_dir)) {
@umask("0000");
if (@mkdir($rep.$user_dir,0777)) {
$fp = fopen($rep.$user_dir."index.html", 'w');
fclose($fp);
} else {
$user_dir=$racine."/users_private/";
}
}
} else {
$user_dir=$racine."/users_private/";
}
if ($upload->saveAs($uname.".".$suffix ,$rep.$user_dir, "B1",true)) {
$user_avatar=$user_dir.$uname.".".$suffix;
$img_size = @getimagesize($rep.$user_avatar);
if (($img_size[0]>$avatar_limit[0]) or ($img_size[1]>$avatar_limit[1])) {
$user_avatar="";
}
}
}
}
}

Pas simple mais marche nickel / a mettre dans le php de gestion du formulaire

A suivre



Cet article provient de NPDS

http://www.npds.org/viewtopic.php?topic=8366&forum=19