Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/10/2009, 01:04
leeann
 
Fecha de Ingreso: febrero-2006
Mensajes: 297
Antigüedad: 18 años, 2 meses
Puntos: 1
Respuesta: subir varias imagenes

No me he enterado, como se haría eso??

Yo tengo esto:

en el index.php

Código PHP:
<?
require("../../../Comun/login.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="/comun/css/Estilos.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/comun/css/swfupload.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/comun/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="/comun/js/swf/swfupload.queue.js"></script>
<script type="text/javascript" src="/comun/js/swf/fileprogress.js"></script>
<script type="text/javascript" src="/comun/js/swf/handlers.js"></script>
<script language="javascript" src="/comun/js/prototype.js"></script>
<script type="text/javascript">
        var swfu;

        window.onload = function() {
            var settings = {
                flash_url : "/comun/js/swfupload/swfupload.swf",
                upload_url: "upload.php?Id=<? echo($Id);?>",
                post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
                file_size_limit : "100 MB",
                file_types : "*.jpg; *.jpeg; *.gif; *.giff; *.png;",
                file_types_description : "All Files",
                file_upload_limit : 100,
                file_queue_limit : 0,
                custom_settings : {
                    progressTarget : "fsUploadProgress",
                    cancelButtonId : "btnCancel"
                },
                debug: false,

                // Button settings
                button_image_url: "/comun/swfupload/SmallSpyGlassWithTransperancy_17x18.png",
                button_width: "100",
                button_height: "18",
                button_placeholder_id: "spanButtonPlaceholder",
                button_text: '<span class="button" style="text-align:center; margin-top:10px;">Seleccionar..</span>',
                button_text_style: '.button { font-family: Times; font-size: 14px;  } .buttonSmall { font-size: 10pt; }',
                button_text_top_padding: 0,
                button_text_left_padding: 18,
                button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
                button_cursor: SWFUpload.CURSOR.HAND,
                
                // The event handler functions are defined in handlers.js
                file_queued_handler : fileQueued,
                file_queue_error_handler : fileQueueError,
                file_dialog_complete_handler : fileDialogComplete,
                upload_start_handler : uploadStart,
                upload_progress_handler : uploadProgress,
                upload_error_handler : uploadError,
                upload_success_handler : uploadSuccess,
                upload_complete_handler : uploadComplete,
                queue_complete_handler : queueComplete    // Queue plugin event
            };

            swfu = new SWFUpload(settings);
         };
    </script>
</head>
<body>

<div id="content">
    
    <form id="form1" action="index.php" method="post" enctype="multipart/form-data">
        

            <div class="fieldset flash" id="fsUploadProgress">
            <span class="legend">Cola de Archivos</span>
            </div>
        <div id="divStatus">0 Archivos subidos</div>
            <div style="margin-top:5px;">
            <div style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
                <span id="spanButtonPlaceHolder"></span>
            </div>
                <input id="btnCancel" type="button" value="Cancelar subidas" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 12px; font-size: 8pt; height: 22px; width:100px;" />
            </div>

    </form>

</div>
</body>
</html>
y upload.php:

Código PHP:
<?php
    
require("../../../Comun/login.php");
    
// Work-around for setting up a session because Flash Player doesn't send the cookies
    
if (isset($_POST["PHPSESSID"])) {
        
session_id($_POST["PHPSESSID"]);
    }

    function 
limpiarfichero($ficherowin)
    {
        
$ficherowin=strtolower($ficherowin);        
        
$ficherowin=str_replace("ñ","n",$ficherowin);        
        
$ficherowin=str_replace("á","a",$ficherowin);
        
$ficherowin=str_replace("é","e",$ficherowin);
        
$ficherowin=str_replace("í","i",$ficherowin);
        
$ficherowin=str_replace("ó","o",$ficherowin);
        
$ficherowin=str_replace("ú","u",$ficherowin);
        
$ficherowin=str_replace("ü","u",$ficherowin);                        
        for (
$i=0;$i<strlen($ficherowin);$i++)
            {
            if((
ord(substr($ficherowin,$i,1))<58 && ord(substr($ficherowin,$i,1))>47) || (ord(substr($ficherowin,$i,1))<124 && ord(substr($ficherowin,$i,1))>96) || ord(substr($ficherowin,$i,1))==46)
                {
$fichero.=substr($ficherowin,$i,1);}
            }
            return 
$fichero;
    }
    
    
$fichero=limpiarfichero($_FILES["Filedata"]['name']);    
    
$nombre=$fichero;
    
$fichero=$_GET["Id"]."~".$fichero;    
    if (!
is_dir("../../../fotos/".$sql_db)){ mkdir("../../../fotos/".$sql_db);}    
    
$fichero_ruta="../../../fotos/".$sql_db."/".$fichero;
    
$temporal=$_FILES["Filedata"]['tmp_name'];
    if(
file_exists ($fichero_ruta)){
        
?>
        <script language="javascript">alert("El fichero ya existe");</script><?
        
exit(0);
    }else {
    
move_uploaded_file($temporal,$fichero_ruta);
    
$tamano=filesize($fichero_ruta);
    
$datos=getimagesize($fichero_ruta);
    
$dimensiones=$datos[0]." X ".$datos[1];    
    
mysql_query("INSERT fotos (Id,Nombre,objeto, Tamano,Dimensiones, fecha) VALUES ('','".$nombre."','".$_GET["Id"]."',".$tamano.",'".$dimensiones."','".date(Y."-".m."-".d)."')") or die(mysql_error());

    }
    
    exit(
0);
?>
Donde devolvería eso del json? Bueno, más bien, como?

También quería añadir esto en algún sitio:

Código PHP:
<script language="javascript">
new Ajax.Updater('fotos', 'fotos.php?Id=<? echo $_GET["Id"]; ?>');
</script>
para que me actualice una capa una vez subidas las fotos, pero tampoco me hace caso!
Se puede hacer??
Estoy buscando por todos lados pero no sé cómo buscar y no encuentro nada!

Muchas gracias