Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/09/2008, 14:33
Avatar de Lynxcraft
Lynxcraft
 
Fecha de Ingreso: noviembre-2007
Ubicación: yecla murcia
Mensajes: 1.346
Antigüedad: 18 años, 10 meses
Puntos: 51
Problema al subir archivo con flash

hola Amig@s tengo un problema y ya no se que hacer XD

la cuestión es que tengo un swf para subir mp3 pero local va perfectamente el problema ocurre al subirlo al host el código que utilizo en el flash es

Código PHP:
stop();
// ajustes iniciales -----------------------------------
System.useCodepage = true;
var 
temas_list:mx.controls.DataGrid;
//evitamos problemas con los nodos en blanco
XML.prototype.ignoreWhite = true;
// defino el estilo global para los componentes
_global.style.setStyle("fontSize",10);

System.security.loadPolicyFile("http://creatusjuegos.com/inicio/subir.php");
System.security.allowDomain("http://creatusjuegos.com");

import flash.net.FileReference;
//creo nuevas columnas en la lista
import mx.controls.gridclasses.DataGridColumn;
temas_list.addColumn("Nombre");
temas_list.addColumn("Categoría ");
temas_list.addColumn("Fecha");

// muestro el scroll sólo si es necesario
temas_list.vScrollPolicy = "auto";

var 
arrTypes:Array = new Array();
var 
objTypes:Object = new Object();
objTypes.description = "Sonido (*.mp3)";
objTypes.extension = "*.mp3; ";

arrTypes.push(objTypes);

var 
listUpload:Object = new Object();
var 
fileUpload:FileReference = new FileReference();
fileUpload.addListener(listUpload);

btbrowse.onRelease = function() {
    
fileUpload.browse(arrTypes);
    
txtestado.text = "";
    
restaura();
};
btenviar.onRelease = function() {
    if (
_root.nombre_usuario == undefined || _root.nombre_usuario == "Anonimo") {
        
txtestado.text = "ERROR: Tienes que estar registrado";
        
error();
    } else {
        if (
txtarchivo.text == "" || txtarchivo.text == undefined) {
            
txtestado.text = "ERROR: Selecciona un archivo";
            
error();
        } else {
            if (
info_nombre.text == "" || info_nombre.text == undefined) {
                
txtestado.text = "ERROR: Es obligatorio un nombre meta del sonido ";
                
error();
            } else {
                if (
lista_cat.value == 0) {
                    
txtestado.text = "ERROR: Selecciona una categoría";
                    
error();
                } else {
                    
restaura();
                    
fileUpload.postData = "action=upload&meta_monbre="+info_nombre.text+"&meta=ssss"+info_mp3.text+"&cat="+lista_cat.value+"&id_usuario="+array_usuario[0].attributes.id;

                    
fileUpload.upload("http://creatusjuegos.com/inicio/subir.php");
                    
info_mp3.text = _url;
                    
txtarchivo.text = "";

                    
info_nombre.text = "";


                }
            }
        }
    }
};
////////////////////ERRORES http//////////
listUpload.onHTTPError = function(file:FileReference, httpError:Number):Void  {
    
txtestado.text = "onHTTPError: "+file.name+httpError;
};

listUpload.onIOError = function(file:FileReference):Void  {
    
txtestado.text = "onIOError: "+file.name;
};

listUpload.onSecurityError = function(file:FileReference, errorString:String):Void  {
    
txtestado.text = "onSecurityError: "+file.name+" errorString: "+errorString;
};

////////--- Fin ERRORES http----///////////



listUpload.onSelect = function(file:FileReference) {
    if (
file.size>1048576) {

        
txtestado.text = "ERROR: NO Puedes Subir Archivos Mayores A 1 MB";
        
error();
        
txtarchivo.text = "";

    } else {
        
// envio de informacion para comparar si el archivo ya existe en la bd
        
var descarga_pro:LoadVars = new LoadVars();
        
descarga_pro.activa = "activa";
        
descarga_pro.id_nombre = file.name;
        
descarga_pro.tamano = file.size;
        
descarga_pro.sendAndLoad("subir.php",descarga_pro,"POST");
        
descarga_pro.onLoad = function() {

            
trace(vere=this.bien);
            
//nota si this.bien es ok es que ya existe un archivo con el mismo nombre 
            
if (vere == "ok") {

                
txtestado.text = "ERROR: Ya has subido un archivo con el mismo nombre y tamaño";
                
error();
                
txtarchivo.text = "";

            } else {
                
restaura();
                
txtarchivo.text = file.name;
                
info_nombrev = file.name.split("_").join(" ").split(".mp3").join("");
            }
        };
    }
};

listUpload.onProgress = function(file, bytesLoaded, bytesTotal):Void  {
    
txtestado.text = "Subiendo archivo "+Math.round(bytesLoaded*100/bytesTotal)+"%";
};
listUpload.onComplete = function(file:FileReference):Void  {
    
txtestado.text = "Archivo subido correctamente";
    
temas_list.removeAll();
    
mostrar_lista(array_usuario[0].attributes.id);
};

var 
array_usuario:Array = new Array();
// objeto XML que carga info de usuario
var iden_xml:XML = new XML();
iden_xml.onLoad = cargarUsuario;
function 
cargarUsuario():Void {

    
array_usuario = this.firstChild.childNodes;
    
_root.nombre_usuario = array_usuario[0].attributes.nombre;
    
_root.id_usuario = array_usuario[0].attributes.id;
    
usuario_info.text = "Usuario: "+array_usuario[0].attributes.nombre;
    
mostrar_lista(array_usuario[0].attributes.id);
}
function 
mostrar_lista(id_cliente) {
    var 
array_id_cliente:Array = new Array();
    
// objeto XML que carga la lista de archivos
    
var lista_xml:XML = new XML();
    
lista_xml.onLoad = cargarLista;
    
// vuelco el contenido del XML
    // en el componente lista
    
function cargarLista():Void {


        
array_id_cliente = this.firstChild.childNodes;
        if (!
isNaN(array_id_cliente.length)) {
            
// numero de temas
            
cantidad_lb.text = array_temp.length+" temas";
            
// relleno la lista

            
for (var k:Number = 0; array_id_cliente[k]; k++) {
                var 
item_obj:Object = {Nombre:array_id_cliente[k].attributes.nombre.split("_").join(" "), Categoria:array_id_cliente[k].attributes.id_cat, Fecha:array_id_cliente[k].attributes.fecha};
                
temas_list.addItem(item_obj);

            }
            
temas_list.spaceColumnsEqually();
        }
    }
    
lista_xml.load("lista_subida.php?id="+id_cliente);
}
iden_xml.load("identificacion.php");
////categoria
var array_temp_c:Array = new Array();
// objeto XML que carga la lista de categoria
var lista_c_xml:XML = new XML();
lista_c_xml.onLoad = cargarLista_c;
// vuelco el contenido del XML
// en el componente lista
function cargarLista_c():Void {
    
//temas_list.removeAll();
    
array_temp_c = this.firstChild.childNodes;
    if (!
isNaN(array_temp_c.length)) {
        
lista_cat.addItem({data:0, label:""});

        for (var 
c:Number = 0; array_temp_c[c]; c++) {

            
lista_cat.addItem({data:array_temp_c[c].attributes.id_cat, label:array_temp_c[c].attributes.nombre});
        }
    }
}


lista_c_xml.load("categoria_mp3.php");
// Cambio el color en la caja de texto si existe algun error
function restaura() {

    
txtestado.backgroundColor = 0xffffff;
}
function 
error() {

    
txtestado.backgroundColor = 0xff3333;
} 
y el código del php que recibe el archivo es

Código PHP:

<?php


 $host
="localhost";                           // nombre del sevidor de la base  
        
$user="root";                                 // nombre del usuario de la base  
        
$bd="mibase1";                             // nombre del base 
        
$passcha="********";                        // clave de le base 
        
        
        
         
$id_usuario=$_POST['id_usuario'];
         
$cat=$_POST['cat'];
         
$meta=$_POST['meta'];
         
$meta_monbre=$_POST['meta_monbre'];
         
// funcion que revisa si el archivo ya existe en al bd

if($_POST['activa'] == "activa"){

         
$code= md5($_FILES['id_nombre'].$_FILES['tamano']);
         
$conexioncha = mysql_connect($host, $user, $passcha);                                
         
mysql_select_db($bd, $conexioncha);
         
$quien = mysql_query("SELECT * FROM mp3_canciones WHERE codigo='$code'") or die(mysql_error());
         
$mp3 = mysql_fetch_array($quien);
             if (
$mp3['codigo'] == $code){
             echo 
"&bien=ok&";
             }
         }
        
//funcion que carha el archivo en el host
if ($_POST["action"] == "upload") {
    
$archivo = $_FILES["Filedata"]['name'];
    
$tamano = $_FILES["Filedata"]['size'];
    
$prefijo = md5($archivo.$tamano);
    if (
$archivo != "") {
         
$destino =  "mp3/".$prefijo;
        
copy($_FILES['Filedata']['tmp_name'], $destino);        
        
$conexioncha = mysql_connect($host, $user, $passcha);                                
         
mysql_select_db($bd, $conexioncha);         
         
$ma=mysql_query ("INSERT INTO mp3_canciones (id_cat, nombre_mp3, codigo, usuario, meta)         
        VALUES ('$cat', '$meta_monbre', '$prefijo', '$id_usuario','$meta' )"
)or die(mysql_error());        
    }
}
?>
como ya digo el código funciona perfectamente en localhost pero deja de funcionar el en servidor

si quieren echarme una mano el flash esta en esta dir

http://creatusjuegos.com/inicio/subir.html

he
__________________
Sobran las ideas cuando faltan ganas de trabajar en ellas
Lynxcraft