Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/07/2009, 08:55
Avatar de aldo1982
aldo1982
 
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 5 meses
Puntos: 6
subir imagen con descripcion de la imagen

buenas gente, bue lo que pogno en el titulo es sencillo de hacer, el tema es que lo estoy queriendo ahcer con la lirberia sffUpload y se me complica a la hora de cautno tengo que ahcer un insert de las equis imagenes seleccioandas en la base de datos y lo mismo para ttomar lso valores de un ccampo de texto apra el nombre de la imagen, no se si em explico bien, aca pongo el codigo a ver si me peuden dar una orientacion.


archivo index.php

Código 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>
<title>SWFUpload Demos - Simple Demo</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/swfupload.queue.js"></script>
<script type="text/javascript" src="js/fileprogress.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
<script type="text/javascript">
        var swfu;

        window.onload = function() {
            var settings = {
                flash_url : "swfupload/swfupload.swf?RandID=<?= rand(1000,2000?>",
                upload_url: "upload.php",
                post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
                file_size_limit : "100 MB",
                file_types : "*.jpg",
                file_types_description : "All Files",
                file_upload_limit : 100,
                file_queue_limit : 100,
                custom_settings : {
                    progressTarget : "fsUploadProgress",
                    cancelButtonId : "btnCancel"
                },
                debug: true,

                // Button settings
                button_image_url: "images/TestImageNoText_65x29.png",
                button_width: "65",
                button_height: "29",
                button_placeholder_id: "spanButtonPlaceHolder",
                button_text: '<span class="theFont">Upload</span>',
                button_text_style: ".theFont { font-size: 16; }",
                button_text_left_padding: 12,
                button_text_top_padding: 3,
                
                // 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">
    <h2>subir imagenes</h2>
  
    <form id="form1" action="index.php" method="post" enctype="multipart/form-data">
        <p>Subida de imagenes multiples</p>

            <div class="fieldset flash" id="fsUploadProgress">
            <span class="legend">Detalle de archivos subidos</span>
            </div>
        <div id="divStatus">0 archivos Subidos</div>
            <div>
                <span id="spanButtonPlaceHolder"></span>
                <input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
        <input type="hidden" id="<?=$_GET[seccion_galeria]?>" />
            </div>

    </form>
</div>
</body>
</html>

archivo upload.php


Código PHP:
<?php
    
include('../../includes/0_incSettings.php');
    include(
"../class.upload/class.upload.php");
    if (isset(
$_POST["PHPSESSID"])) {
        
session_id($_POST["PHPSESSID"]);
    }
    
session_start();
    
//funcion para eliminar caracteres no permitidos en las urls
    
function obtener_extension_archivo($rutaCompleta) {
        
$partes_ruta_array pathinfo($rutaCompleta);    
        
$extension_obtenida $partes_ruta_array['extension'];
        return 
$extension_obtenida;
    }
    function 
urls_amigables_img($url) {
    
        
// Tranformamos todo a minusculas
        
        
$url strtolower($url);
        
        
//Rememplazamos caracteres especiales latinos
        
        
        
$find = array('á','é','í','ó','ú','ñ');
        
$repl = array('a','e','i','o','u','n');
        
$url eregi_replace ($find$repl$url);
        
        
$find = array('à','è','ò');
        
$repl = array('a','e','o');
        
$url eregi_replace ($find$repl$url); 
        
        
// Añaadimos los guiones
        
        
$find = array(' ''&''\r\n''\n''+');
        
$url str_replace ($find'-'$url);
        
        return 
$url;
    
    }
    
    if (!isset(
$_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
        
// Usually we'll only get an invalid upload if our PHP.INI upload sizes are smaller than the size of the file we allowed
        // to be uploaded.
        
header("HTTP/1.1 500 File Upload Error");
        if (isset(
$_FILES["Filedata"])) {
            echo 
$_FILES["Filedata"]["error"];
        }
        exit(
0);
        
    }
    else
    {
        
$nombre_archivo $_FILES['Filedata']['name'];//obtenemos el nombre del archivo        
        
$nombre_archivo urls_amigables_img($nombre_archivo);    
        
$ruta_upload "archivos_subidos"$nombre_archivo;    
        
$ruta_upload_images PATH.IMG_MENU_VERTICAL."galeria_".$_POST[id_cont]."/";
        
        
$id_insertar maximo_tabla('galeria_mv''id_foto'1);
        
$handle = new Upload($_FILES['Filedata']);
        
$handle->file_new_name_body $id_insertar.'_grande';
        
$handle->image_resize          true;
        
$handle->image_ratio_y         true;
        
$handle->image_x               500;
        
$handle->jpeg_quality          80;
        
        
                
        
//move_uploaded_file($_FILES['Filedata']['tmp_name'],$ruta_upload);
    
}
    
?>
<!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>
    <title>SWFUpload v2.0 Multi-Upload Demo</title>
</head>
<body>
    <p>Upload Page</p>
</body>
</html>
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA