sorry i did not posted the entire procedure (too long), here it is :
Thanks a lot for your analyse.
#---------------------------------------------------------------#
# #
# sub fadd #
# #
#---------------------------------------------------------------#
sub fadd {
my $dm_sid = $_[0];
my $dm_user = $_[1];
my $dm_passwd = $_[2];
my $dm_dbh = $_[3];
my $dm_rep = $_[4];
my $dm_fic = $_[5];
my $ficgenpath;
my $nomfic;
my $file=$dm_fic;
my $bytesread;
my $maxsize=50000000;
my $OUTFILE;
my @msg;
if ($ENV{CONTENT_LENGTH} <= $maxsize)
{
# test de la syntaxe du fichier : si vide
if ($dm_fic ne '')
{
#netscape + opera = sans path windows/unix
#ie = avec path windows/unix
if ( $file =~ /(\\|\/)/ )
{
#iexplorer avec path local filesystem
$dm_fic =~ s/^.*(\\|\/)//;
$nomfic=$dm_fic;
}
else
{
#netscape opera sans path local filesystem
$nomfic=$file;
}
push (@msg, "file=$file");
push (@msg, "nomfic=$nomfic");
# test de la syntaxe du fichier apres traitement du path
#if ($nomfic =~ /^[A-Za-z0-9\-_\.]+$/)
if ($nomfic)
{
$ficgenpath =
'/usr/local/apache2/htdocs/users/'.$dm_user.'/'.$dm_rep.'/'.$nomfic;
push (@msg, "Ajout de fichier $ficgenpath");
#teste si le fic existe --pb de cache web
my $sth = $dm_dbh->prepare("SELECT * FROM Files WHERE Fic_Nom='$nomfic' and
Fic_Dir_Nom='$dm_rep' and Fic_User_Id='$dm_user'");
my $retval=$sth->execute(); #retval=1=ok
$sth->finish();
if ($retval == 1)
{
push (@msg, 'Le fichier existe deja !');
}
else
{
# reception file system
push (@msg, 'Reception du fichier...');
if (open(OUTFILE, ">$ficgenpath"))
{
binmode(OUTFILE);
while ($bytesread = read($file, my $buffer, 1024)) {
print OUTFILE $buffer;
}
#while(<$file>) {
#print OUTFILE $_;
#}
close OUTFILE;
# taille
my $inode = stat($ficgenpath);
my $size = $inode->size;
push (@msg, "$ficgenpath,size=$size");
if ($size != 0) {
push (@msg, "Creation du fichier :$ficgenpath : ok...");
# ajoute le fichier
# calcul de la date date courante plus 1 mois
my $tm = localtime;
(my $cday, my $cmonth, my $cyear) = ($tm->mday, $tm->mon, $tm->year);
# bug si 31
if ($cday == 31) {$cday--;}
(my $eyear, my $emonth, my $eday) = Add_Delta_Days($cyear, $cmonth, $cday,
30);
$eyear=$eyear+1900;
$emonth=$emonth+1;
my $edate = $eyear.'-'.$emonth.'-'.$eday;
my $sql = qq/INSERT INTO Files
values('$dm_fic','$dm_rep','$dm_user','$edate','S')/;
eval { $dm_dbh->do( $sql )};
if ( $@ )
{
push (@msg, "Mysql error : Insert failed : $@");
}
else
{
push (@msg, 'Insert OK');
}
}
else
{
push (@msg, 'Erreur le fichier est vide !');
}
}
else
{
push (@msg, 'Erreur de creation de fichier !');
}
}
}
else
{
push (@msg, 'Erreur de syntaxe : le nom du fichier est incorrect !');
}
}
else
{
push (@msg, 'Erreur de syntaxe : le nom du fichier est incorrect !');
}
}
else
{
push (@msg , "Entrenoo : ATTENTION fichier trop gros : $ENV{CONTENT_LENGTH}
octets, limite de 50mo !");
}
noo::console(\@msg);
} #end fadd
Purl said:
Lionel Valero wrote:
You have not defined your $ficgenpath variable.
Your script fails at this point. It is not
possible for you to upload a file, as you
have previously indicated.
Purl Gurl
--
-=O=------------------------------------------=O=-
Lionel Valéro
Analyste Informatique Département Génie Chimique
École Polytechnique de Montréal
C.P. 6079, succ. centre-ville
Montréal (Québec) H3C 3A7
Tel: (514) 340 - 4711 # 4805 / C552
Fax: (514) 340 - 4159
-=O=------------------------------------------=O=-