From 2e26eeea1e262062d21ee621b3bf15d995bf0f30 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 17 Jun 2003 14:36:36 +0000 Subject: [PATCH] Gestion des fichiers --- htdocs/comm/docsoc.php | 99 +++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/htdocs/comm/docsoc.php b/htdocs/comm/docsoc.php index 8ee05484356..898220d8a13 100644 --- a/htdocs/comm/docsoc.php +++ b/htdocs/comm/docsoc.php @@ -24,37 +24,30 @@ llxHeader(); $db = new Db(); +$upload_dir = SOCIETE_DOCUMENT_DIR . "/" . $socid . "/"; -function do_upload ($socid) { - global $uploadfile, $uploadfile_size; +function do_upload ($socid) +{ + global $upload_dir; global $local_file, $error_msg; - if ( $uploadfile == "none" ) + if (! is_dir($upload_dir)) { - $error_msg = "You did not specify a file for uploading."; - return; - } - if ( $uploadfile_size > 2000000 ) - { - $error_msg = "Sorry, your file is too large."; - return; - } - - $soc_dir = SOCIETE_DOCUMENT_DIR . "/" . $socid; - - if (! is_dir($soc_dir)) - { - mkdir($soc_dir); + mkdir($upload_dir, 0755); } - $upload_dir = "/tmp"; - - $local_file = SOCIETE_DOCUMENT_DIR . "/" . $socid . "/"; - - move_uploaded_file ( $userfile, $local_file ); - - print $HTTP_POST_FILES['uploadfile']['name']; + if (move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . $_FILES['userfile']['name'])) + { + print "Le fichier est valide, et a été téléchargé + avec succès. Voici plus d'informations :\n"; + //print_r($_FILES); + } + else + { + echo "Le fichier n'a pas été téléchargé"; + // print_r($_FILES); + } } @@ -62,6 +55,12 @@ if ( $error_msg ) { echo "$error_msg

"; } +if ($action=='delete') +{ + $file = $upload_dir . urldecode($urlfile); + dol_delete_file($file); +} + if ( $sendit ) { do_upload ($socid); @@ -78,7 +77,7 @@ if ($socid > 0) { $societe = new Societe($db, $socid); - $sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as dc, s.tel, s.fax, st.libelle as stcomm, s.fk_stcomm, s.url,s.address,s.cp,s.ville, s.note, t.libelle as typent, e.libelle as effectif, s.siren, s.prefix_comm, s.services,s.parent, s.description FROM societe as s, c_stcomm as st, c_typent as t, c_effectif as e "; + $sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as dc, s.tel, s.fax, st.libelle as stcomm, s.fk_stcomm, s.url,s.address,s.cp,s.ville, s.note, t.libelle as typent, e.libelle as effectif, s.siren, s.prefix_comm, s.services,s.parent, s.description FROM llx_societe as s, c_stcomm as st, c_typent as t, c_effectif as e "; $sql .= " WHERE s.fk_stcomm=st.id AND s.fk_typent = t.id AND s.fk_effectif = e.id"; @@ -100,7 +99,6 @@ if ($socid > 0) print "\n"; print ""; - print ""; print ""; print ""; print ""; @@ -122,16 +120,15 @@ if ($socid > 0) print ""; print ""; - print ""; - print "
Fiche client : $objsoc->nom
idp&action=add_bookmark\">[Bookmark]idp&action=create\">[Projet]idp&action=create\">[Propal]idp\">Notes
sirensiren\">$objsoc->siren prefix"; - if ($objsoc->prefix_comm) { - print $objsoc->prefix_comm; - } else { - print "[idp&action=attribute_prefix\">Attribuer]"; - } + if ($objsoc->prefix_comm) + { + print $objsoc->prefix_comm; + } else { + print "[idp&action=attribute_prefix\">Attribuer]"; + } print "
Siteurl\">$objsoc->url 
"; /* @@ -143,15 +140,39 @@ if ($socid > 0) echo '
'; - print ''; + print ''; print ''; - print '

'; - print ''; - print '
'; + print '
'; + print ''; + print '
'; print '
'; - - + clearstatcache(); + + $handle=opendir($upload_dir); + + print ''; + + while (($file = readdir($handle))!==false) + { + if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + print '\n"; + + print ''; + print ''; + + print '\n"; + } + } + + print "
'; + echo ''.$file.''; + print "'.filesize($upload_dir."/".$file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($upload_dir."/".$file)).''; + echo 'Delete'; + print "
"; + + closedir($handle);