Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/01/2015, 05:27
camilomascarell1987
 
Fecha de Ingreso: abril-2013
Mensajes: 39
Antigüedad: 11 años, 1 mes
Puntos: 0
subir imagenes multiples mysql

Bueno tarde
Como subir multiples imagenes solo mysql nuevo siempre?
Código PHP:
<?php require_once('../../Connections/fotos.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  
session_start();
}

// ** Logout the current user. **
$logoutAction $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset(
$_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  
$logoutAction .="&"htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  
//to fully log out a visitor we need to clear the session varialbles
  
$_SESSION['MM_Username'] = NULL;
  
$_SESSION['MM_UserGroup'] = NULL;
  
$_SESSION['PrevUrl'] = NULL;
  unset(
$_SESSION['MM_Username']);
  unset(
$_SESSION['MM_UserGroup']);
  unset(
$_SESSION['PrevUrl']);
    
  
$logoutGoTo "index.php";
  if (
$logoutGoTo) {
    
header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  
session_start();
}
$MM_authorizedUsers "";
$MM_donotCheckaccess "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 
  
// For security, start by assuming the visitor is NOT authorized. 
  
$isValid False

  
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  
if (!empty($UserName)) { 
    
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    
$arrUsers Explode(","$strUsers); 
    
$arrGroups Explode(","$strGroups); 
    if (
in_array($UserName$arrUsers)) { 
      
$isValid true
    } 
    
// Or, you may restrict access to only certain users based on their username. 
    
if (in_array($UserGroup$arrGroups)) { 
      
$isValid true
    } 
    if ((
$strUsers == "") && true) { 
      
$isValid true
    } 
  } 
  return 
$isValid
}

$MM_restrictGoTo "index.php";
if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  
$MM_qsChar "?";
  
$MM_referrer $_SERVER['PHP_SELF'];
  if (
strpos($MM_restrictGoTo"?")) $MM_qsChar "&";
  if (isset(
$_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0
  
$MM_referrer .= "?" $_SERVER['QUERY_STRING'];
  
$MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);
  
header("Location: "$MM_restrictGoTo); 
  exit;
}
?>
<?php
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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
  
$insertSQL sprintf("INSERT INTO imagenesgaleria (id_galeria, id_usuario, imagenes) VALUES (%s, %s, %s)",
                       
GetSQLValueString($_POST['select'], "text"),
                       
GetSQLValueString($_POST['usuario'], "text"),
                       
GetSQLValueString($_FILES['imagenes']["name"], "text"));
                       
                       
    
ini_set('display_errors','On');
$target getcwd()."/../galerias/"
$target $target basename$_FILES['imagenes']['name']) ;  

if (
move_uploaded_file($_FILES['imagenes']['tmp_name'], $target)) { 
    echo 
"el archivo "basename$_FILES['uploadedfile']['name']). " se ha subido";
    } else { 
    echo 
"Algo salió mal."
    } 

  
mysql_select_db($database_fotos$fotos);
  
$Result1 mysql_query($insertSQL$fotos) or die(mysql_error());

  
$insertGoTo "galeriaeditar.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

mysql_select_db($database_fotos$fotos);
$query_galeriausuario "SELECT usuarios FROM usuario";
$galeriausuario mysql_query($query_galeriausuario$fotos) or die(mysql_error());
$row_galeriausuario mysql_fetch_assoc($galeriausuario);
$totalRows_galeriausuario mysql_num_rows($galeriausuario);

mysql_select_db($database_fotos$fotos);
$query_galeriatitulos "SELECT titulos FROM galerias";
$galeriatitulos mysql_query($query_galeriatitulos$fotos) or die(mysql_error());
$row_galeriatitulos mysql_fetch_assoc($galeriatitulos);
$totalRows_galeriatitulos mysql_num_rows($galeriatitulos);
?>
<?php
include('header.php');
?>
<div id="contenido">
<div id="galerias1">
<div id="galerias-admin"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td><a href="admin.php">Administrador</a> - Digital Flash</td>
      <td><a href="<?php echo $logoutAction ?>">Salir</a></td>
    </tr>
  </tbody>
</table>
<br/>
<form method="POST" action="<?php echo $editFormAction?>" name="form" enctype="multipart/form-data">
  <label for="usuario">Usuario:</label>
  <select name="usuario" id="usuario">
    <?php
do {  
?>
    <option value="<?php echo $row_galeriausuario['usuarios']?>"<?php if (!(strcmp($row_galeriausuario['usuarios'], $row_galeriausuario['usuarios']))) {echo "selected=\"selected\"";} ?>><?php echo $row_galeriausuario['usuarios']?></option>
    <?php
} while ($row_galeriausuario mysql_fetch_assoc($galeriausuario));
  
$rows mysql_num_rows($galeriausuario);
  if(
$rows 0) {
      
mysql_data_seek($galeriausuario0);
      
$row_galeriausuario mysql_fetch_assoc($galeriausuario);
  }
?>
  </select>
  <label for="select">Carpeta galerias:</label>
  <select name="select" id="select">
    <?php
do {  
?>
    <option value="<?php echo $row_galeriatitulos['titulos']?>"<?php if (!(strcmp($row_galeriatitulos['titulos'], $row_galeriatitulos['titulos']))) {echo "selected=\"selected\"";} ?>><?php echo $row_galeriatitulos['titulos']?></option>
    <?php
} while ($row_galeriatitulos mysql_fetch_assoc($galeriatitulos));
  
$rows mysql_num_rows($galeriatitulos);
  if(
$rows 0) {
      
mysql_data_seek($galeriatitulos0);
      
$row_galeriatitulos mysql_fetch_assoc($galeriatitulos);
  }
?>
  </select>
  <label for="imagenes">Fotográfico:</label>
  <input name="imagenes" type="file" multiple="multiple" id="imagenes"><br/>
  <input type="submit" name="submit" id="submit" value="Enviar">
  <input type="hidden" name="MM_insert" value="form">
</form>
</div>
</div>
</div>

<?php
include('footer.php');
?>
<?php
mysql_free_result
($galeriausuario);

mysql_free_result($galeriatitulos);
?>