Código PHP:
    <?php require_once('../../Connections/comercio_electronico.php'); ?>
<?php
session_start();
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$colname_user = "-1";
if (isset($_SESSION['usuario'])) {
  $colname_user = $_SESSION['usuario'];
}
mysql_select_db($database_comercio_electronico, $comercio_electronico);
$query_user = sprintf("SELECT * FROM grupos_usuarios WHERE usuario = %s", GetSQLValueString($colname_user, "text"));
$user = mysql_query($query_user, $comercio_electronico) or die(mysql_error());
$row_user = mysql_fetch_assoc($user);
$totalRows_user = mysql_num_rows($user);
 
 
?><?php
if (isset($_SESSION['usuario'])){
     if($row_user['nombre']==NULL){
     header('Location: login.php');
     }else{
     }
}else{
      header('Location: login.php');
}
      ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Grupos - Contratos</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #EAEAEA;
}
-->
</style>
<link href="../../css/clases.css" rel="stylesheet" type="text/css" />
<link href="../../css/evo_mew.css" rel="stylesheet" type="text/css" />
<link href="../../css/styles_new.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {color: #FFFFFF; }
a:link {
    color: #FF0000;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #FF0000;
}
a:hover {
    text-decoration: underline;
    color: #FF0000;
}
a:active {
    text-decoration: none;
    color: #FF0000;
}
-->
</style>
<script src="../../js/jquery-1.4.4.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="../../css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />
        <script src="../../js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
  });
</script>
<script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/documentation.js" type="text/javascript"></script>
 <link href="documentation.css" type="text/css" rel="stylesheet"/>
 <!--// code-highlighting //-->
    <script type="text/javaScript" src="/jquery/project/chili/jquery.chili-2.0.js"></script> 
    <script type="text/javaScript" src="/jquery/project/chili-toolbar/jquery.chili-toolbar.pack.js"></script> 
 <script type="text/javascript">try{ChiliBook.recipeFolder="/jquery/project/chili/"}catch(e){}</script>
 <!--// plugin-specific resources //-->
 <script src="js/jquery.form.js" type="text/javascript" language="javascript"></script>
    <script src="js/jquery.MetaData.js" type="text/javascript" language="javascript"></script>
 <script src="js/jquery.MultiFile.js" type="text/javascript" language="javascript"></script>
 <script src="js/jquery.blockUI.js" type="text/javascript" language="javascript"></script>
 <script language="JavaScript">
function pregunta(){
    return confirm('¿Estas seguro de borrar este adjunto?'); 
}
</script> 
</head>
 
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="middle"><div align="center">
      <table width="500" border="1">
        <tr>
          <td width="429"><form action="adjuntosg.php?id_contrato=<?PHP echo $_GET['id_contrato'];?>" method="post" enctype="multipart/form-data" name="form1">
            <p>
              <input name="ffoto[]" type="file" class="multi" accept="png|gif|jpg|jpeg|pdf|doc|docx|xls|pptx|xlsx" maxlength="5" />
              <input name="id_contrato" type="hidden" id="id_contrato" value="<?PHP echo $_GET['id_contrato'];?>">
              <input type="submit" name="button" id="button" value="Agregar">
              <input name="envia" type="hidden" id="envia" value="SI">
            </p>
           <?php 
           if($_POST['envia']=="SI"){
    $id = $_POST['id_contrato'];
        $cuales="";
            /// Vemos cuantos archivos hemos subido
        $nro=count($_FILES["ffoto"]["name"]);
    if($nro==0){
    echo "<font color='#FF0000'>Seleccione un archivo</font>";
    }
    /// Empezamos el array
    for ($i=0; $i<$nro; $i++) {
    $file_name=$_FILES["ffoto"]["name"][$i];
    $file_size=$_FILES["ffoto"]["size"][$i];
    $file_type=$_FILES["ffoto"]["type"][$i];
    $idUnico = time();
    if($file_name!=""){
        // verifica carpeta
        $nombre_archivo=$_POST['femail'];
        if (!file_exists('archivos/'.$nombre_archivo)) {
            mkdir('archivos/'.$nombre_archivo,0777);
        }
        $path="archivos/".$nombre_archivo;     
        // sube archivo
        copy($_FILES["ffoto"]['tmp_name'][$i], $path.'/'.$idUnico.$file_name) ;
         $nombre_foto=$idUnico.$file_name;
         $consulta="insert into grupos_archivos (id_contrato, nombre, archivo) values('$id', '$file_name', '$nombre_foto')";
         mysql_query($consulta);
          echo '<p align="left">El archivo <b>'.$file_name.'</b> fue subido correctamente.</p>';
        $cuales.=$file_name." ";
        } else {
        echo '<br><br><p align="left"><b>Error with '.$file_name.'</b></p>';
        }
    }
           }
           
           $colname_archivos = "-1";
if (isset($_GET['id_contrato'])) {
  $colname_archivos = $_GET['id_contrato'];
}
mysql_select_db($database_comercio_electronico, $comercio_electronico);
$query_archivos = sprintf("SELECT * FROM grupos_archivos WHERE id_contrato = %s", GetSQLValueString($colname_archivos, "int"));
$archivos = mysql_query($query_archivos, $comercio_electronico) or die(mysql_error());
$row_archivos = mysql_fetch_assoc($archivos);
$totalRows_archivos = mysql_num_rows($archivos);
    ?>
          </form></td>
          <td width="61" align="left" valign="top">[<a href="contratosg.php">volver</a>]</td>
        </tr>
        <?php do { ?>
          <?php if ($totalRows_archivos > 0) { // Show if recordset not empty ?>
  <tr>
    <td><a href="archivos/<?php echo $row_archivos['archivo']; ?>" target="_blank"><?php echo $row_archivos['nombre']; ?></a></td>
    <td><form id="form1" name="form1" method="post" action="borrar_adjuntog.php" ONSUBMIT="return pregunta();">
      <input name="id_archivo" type="hidden" id="id_archivo" value="<?php echo $row_archivos['id']; ?>">
      <input name="image" type=image  src="../../img/icons/fail.gif" width="16" height="16" />
      <input name="id" type="hidden" id="id" value="<?php echo $row_archivos['id_contrato']; ?>">
    </form></td>
  </tr>
  <?php } // Show if recordset not empty ?>
          <?php } while ($row_archivos = mysql_fetch_assoc($archivos)); ?>
      </table>
    </div></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($user);
 
mysql_free_result($archivos);
?>    
  Gracias