Ver Mensaje Individual
  #13 (permalink)  
Antiguo 16/01/2006, 04:48
3ws
 
Fecha de Ingreso: diciembre-2005
Mensajes: 9
Antigüedad: 18 años, 3 meses
Puntos: 0
Por fin consegui subir las imagenes a FTP

Este es el código php que he utilizado para subir las fotos.
Es un poco cutrecillo pero a mi me ha servido. El unico problema son los permisos que da en la ftp a las fotos, que son 600 y creo que deberian ser 664.
Estoy buscando la forma de cambiarlos.
Muchas gracias por la ayuda

Código PHP:
<?$id=$_REQUEST['id'];
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_update"])) && ($_POST["MM_update"] == "form1")) {
  
$updateSQL sprintf("UPDATE eventos SET foto_g=%s,foto_p=%s WHERE id='$id'",
                        
GetSQLValueString($_FILES['foto_g']['name'], "text"),
                        
GetSQLValueString($_FILES['foto']['name'], "text"));

  
mysql_select_db($database_uno$uno);
  
$Result1 mysql_query($updateSQL$uno) or die(mysql_error());

    if ( isset (
$_POST['enviar'])){
        if (!empty (
$_FILES['foto']['tmp_name'])){
            
move_uploaded_file ($_FILES['foto']['tmp_name'],
            
"carpeta"$_FILES['foto']['name']);
        }
        if (!empty (
$_FILES['foto_g']['tmp_name'])){
            
move_uploaded_file ($_FILES['foto_g']['tmp_name'],
            
"carpeta"$_FILES['foto_g']['name']);
        }
    }
          if (isset(
$_SERVER['QUERY_STRING'])) {
            
$updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
            
$updateGoTo .= $_SERVER['QUERY_STRING'];
          }
          
header(sprintf("Location: %s"$updateGoTo));
    }
}

mysql_select_db($database_ensingular$ensingular);
$query_sql "SELECT * FROM eventos";
$sql mysql_query($query_sql$ensingular) or die(mysql_error());
$row_sql mysql_fetch_assoc($sql);
$totalRows_sql mysql_num_rows($sql);
?>

    
<?php
mysql_free_result
($sql);
?>