Comunidad de diseño web y desarrollo en internet online

FILE REFERENCE, NO FUNCIONA!!!

Citar            
MensajeEscrito el 25 Sep 2007 03:43 am
Hola todos tengo un error con el tutorial de Tmeinster sobre FileReference, pues quiero probar este codigo pero no me sube ningun archivo,
utilizo el "The AppServ Open Project - 2.4.8 for Windows " para probar scritp php, pero nada no resulta, si alguien me dice que pasa o
q puedo estar haciendo mal, yo modifico
var path:String = "http://localhost/uploadDir"
y no funciona.. espero sus comentarios en esta ayuda..

//Codigo completo

Código :

import flash.net.FileReference;  
   var fileUpload:FileReference = new FileReference();  
   var path:String = "http://www.klr20mg.com/uploadDir"  
   var escucha:Object = {};  
   var fileTypes:Array;  
   var getFile:String;  function init() {  
      System.security.allowDomain(path);  
      load_mc._visible = false;     
      fileTypes = [{description:"Archivos de Imagen", extension:"*.jpg;*.gif;*jpeg;*.png", macType:"JPEG;jp2_;GIFF"}];
      upload_btn.label = "Upload File";   
      down_btn.label = "Download File"; 
      upload_btn.addEventListener("click", doUpload); 
      down_btn.addEventListener("click", doDownload); 
      fileUpload.addListener(escucha); 
      escucha.onSelect = doSelect;  
      escucha.onComplete = doComplete; 
      escucha.onCancel = doCancel; 
      escucha.onProgress = doProgress; 
      data_mc.addEventListener("change", setDownload); 
      makeList();
      } 
   function doComplete() {     
   load_mc.barra_mc._xscale = 0;  
   load_mc.label_txt.text = "Tranferencia Completa";
   makeList();  
      }
   function doProgress(archivo:FileReference, bLoaded:Number, bTotal:Number) {  
      var porcentaje = Math.round((bLoaded*100)/bTotal);
      load_mc.label_txt.text = porcentaje+"% del archivo "+archivo.name;     
      load_mc.barra_mc._xscale = porcentaje; 
      }
   function doCancel() { 
      trace("El Usuario Cancelo");
      }
   function doSelect(archivo:FileReference) {  
      load_mc._visible = true; 
      load_mc.barra_mc._xscale = 0;
      fileUpload.upload(path+"/uploadFile.php");  
      }
   function doDownload() {  
      if (getFile != undefined) {  
      fileUpload.download(path+"/"+getFile);  
      }
   }
function doUpload(event) {     
   fileUpload.browse(fileTypes);  
   }  
function setDownload(c:MovieClip) {  
   getFile = c.target.selectedItem.Nombre;
   }  
function makeList() {  
   data_mc.removeAll();  
   var list_xml:XML = new XML(); 
   list_xml.ignoreWhite = true;  
   list_xml.load(path+"/lista.php");     
   list_xml.onLoad = function() {     
      var nodos = this.firstChild.childNodes;     
      for (var a in nodos) {        
         var size:Number = Math.ceil((nodos[a].attributes.tamanio/1024));     
         data_mc.addItem({Nombre:nodos[a].attributes.name, Tamaño:size+" Kb"}); 
         } 
      }; 
   } 
init();

//uploadFile.php

Código :

<?php  
   $uploadDir = './';
   $uploadFile = $uploadDir . $_FILES['Filedata']['name'];
   move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadFile); 
 ?>

//list.php


Código :

<?php  
   $No=array(".","..","lista.php","uploadFile.php");  
   $fp=opendir("."); 
   echo "<?xml version='1.0' ?".">"; 
   echo "<files>";  
   while (false!==($file=readdir($fp))){     
      if ((!in_array($file,$No))&&(is_readable($file))){     
         echo "<file name='".utf8_encode($file)."' tamanio='".filesize($file)."' />";
         }  
      } 
   closedir($fp);  
   echo "</files>"; 
 ?>
[/code]

Por Sochmal

53 de clabLevel



 

cuenca

msie
Citar            
MensajeEscrito el 28 Ago 2009 01:18 pm
Tu servidor debe soportar minimo php4 para que este script funcione...si queires que te ayude lo puedo subir a mi server y hay haces la prueva... :lol:

Por robertosebastian92

88 de clabLevel

1 tutorial

 

1 mes

firefox
Citar            
MensajeEscrito el 28 Ago 2009 07:56 pm
Gracias, voy a realizar las ultimas pruebas a ver si corre.. Saludos

Por Sochmal

53 de clabLevel



 

cuenca

msie7
Citar            
MensajeEscrito el 28 Ago 2009 07:56 pm
Gracias, voy a realizar las ultimas pruebas a ver si corre.. Saludos

Por Sochmal

53 de clabLevel



 

cuenca

msie7

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.