Foros del Web » Creando para Internet » Flash y Actionscript »

Comprobar extension del fichero para dar error

Estas en el tema de Comprobar extension del fichero para dar error en el foro de Flash y Actionscript en Foros del Web. hola estoy con un upload de files y tengo hecho el sistema para el tamaño maximo de fichero, si sobre pasa pues error, ahora bien,,, ...
  #1 (permalink)  
Antiguo 18/04/2007, 12:46
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Pregunta Comprobar extension del fichero para dar error

hola estoy con un upload de files y tengo hecho el sistema para el tamaño maximo de fichero, si sobre pasa pues error, ahora bien,,, me gustaria añadirle tb un sistema para la extension del fichero... por ejemplo si es

*.EXE = false
*.RAR = false
*.JPG = true
*.GIF = true

dejo aqui el code del tamaño---

Código PHP:
    public function fileRefListener_onSelect(fileRefList:FileReferenceList){
        var list:Array = 
fileRefList.fileList;
        var 
tempList = new Array();

        for(var 
i=0i< list.lengthi++){
            var 
sizeFile = list[i].size/1024/1024//in MB
            
if((sizeFile maxFilesize) || (sizeFile >= 150)){ //150 MB is Flash Player limit per file
/**********************************************************************************************************/
                
frWindow.content.feedback_txt.htmlText "<p align='center'>Maximo 150 MB: El fichero excede del tamaño ("+Math.ceil(sizeFile)+" MB)";
/**********************************************************************************************************/
            
}else{
                
tempList.push(list[i])
            }
            
        }
        
        
        
        
        
filesToUpload filesToUpload.concat(tempList);
        
frWindow.content.fileList_grid.dataProvider filesToUpload;
        
checkGridItems();
    } 
alguien me puede ayudar¿? necesitan algo mas de code¿

gracias
  #2 (permalink)  
Antiguo 18/04/2007, 13:41
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Re: Comprobar extension del fichero para dar error

se podria comprobar con expresiones regulares? hoy se usa otro metodo ?
  #3 (permalink)  
Antiguo 18/04/2007, 15:52
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Re: Comprobar extension del fichero para dar error

puede ser que el nombre del fichero este aqui en esta funcion?

Código PHP:
public function setupFilesGrid(){
        var 
theGrid frWindow.content.fileList_grid;

        var 
column = new DataGridColumn("name");
        
column.headerText "    Nombre Fichero";
        
column.width 600;
        
theGrid.addColumn(column);        

/***********************************************/
        
varss frWindow.content.fileList_grid;
        
trace(varss);
/***********************************************/
        
        
var column = new DataGridColumn("size");
        
column.headerText "     Tamaño";
        
column.width 100;
        
column.labelFunction = function(item):String {
            if ((
item.size != undefined) && (item.name != undefined)) {
                return ((
Math.ceil(item.size/1024)) + " KB");
            }
        }

        
theGrid.addColumn(column);            
    } 
  #4 (permalink)  
Antiguo 18/04/2007, 15:56
 
Fecha de Ingreso: septiembre-2006
Mensajes: 1.193
Antigüedad: 17 años, 6 meses
Puntos: 30
Re: Comprobar extension del fichero para dar error

hay un foro de php ahi te ayudan mejor para eso
  #5 (permalink)  
Antiguo 18/04/2007, 16:04
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Pregunta Re: Comprobar extension del fichero para dar error

umm RIZO no es cuestion de PHP, es cuestion de que necesito el nombre del fichero que muestra en el GRID, asi con ese nombre, yo puedo desde FLASH, hacer una comprobacion con un IF de si existe o no la cadena .jpg , .gif , si no existe ya muestro un error al usuario igual que lo hago en la parte del tamaño de fichero.

de hecho ya tengo la condicion de la cadena de texto, en plan cutre hasta q pueda descubrir como sacar el dichoso nombre...

Código PHP:
if(_root.mystring.findstring(varss)){
    
trace("NO LO ENCONTRO !!!");
    
frWindow.content.feedback_txt.htmlText "<p align='center'>El tipo de fichero no esta permitido: Seleccione | *.rar | *.zip | *.ace | *.iso | *.bin | *.7z |";
}else{
    
tempList.push(list[i])
}

String.prototype.findstring=function(string){
    if(
this.indexOf(string) != -1){
        return 
true
    
}else{
        return 
false
    
}


ves.... ahora bien... yo cuando cargo el fichero veo el nombre en el GRID, osea q el nombre sale de algun lado... ahora como lo capturo? y lo paso a una simple variable = name_file???

thank you


si necesitan el code entero, sere gustoso de mostrarlo
  #6 (permalink)  
Antiguo 18/04/2007, 16:06
 
Fecha de Ingreso: septiembre-2006
Mensajes: 1.193
Antigüedad: 17 años, 6 meses
Puntos: 30
Re: Comprobar extension del fichero para dar error

si subelo para verlo
  #7 (permalink)  
Antiguo 18/04/2007, 16:12
 
Fecha de Ingreso: septiembre-2006
Mensajes: 1.193
Antigüedad: 17 años, 6 meses
Puntos: 30
Re: Comprobar extension del fichero para dar error

Código:
import flash.net.FileReference;
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void  {
	trace("Tipo: "+file.type);
	if (file.type == ".swf") {
		trace("error tipo de archivo es swf");
	}
	trace("Tipo: "+file.type);
};
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse();
selecciona un .swf y ve que pasa espero te sirva
  #8 (permalink)  
Antiguo 18/04/2007, 16:14
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Re: Comprobar extension del fichero para dar error

Código PHP:
/*
FileUpload.as
Sascha Wenning
Jan 2006

Feel free to customize for your needs
Code is partly documentated
*/

import mx.controls.gridclasses.DataGridColumn;
import flash.net.FileReference;
import flash.net.FileReferenceList;
import mx.containers.Window;
import mx.utils.Delegate;

class 
de.saschawenning.fileUpload.FileUpload{
    private var 
tl:MovieClip;
    private var 
titleWindow:String;
    private var 
frWindow:MovieClip//path to windowComponent
    
private var uploadMode;
    private var 
xCoord;
    private var 
yCoord;
    private var 
uploadDir;    
    private var 
pathUploadScript;
    private var 
pathXmlFileStructure;
    private var 
varss;
    
    private var 
waiter;
    private var 
xmlFileStructure;
    private var 
fileRef;
    private var 
fileRefListener;
    private var 
filesToUpload:Array;
    private var 
totalKilobytesToUpload;
    private var 
totalKiloBytesUploaded;
    private var 
filesUploaded//num of files uploaded
    
private static var maxFilesize//in MB per file you can set this also by hand to limit it
    
private var labelUploadBtn;
    

    public function 
FileUpload(timelinetitleWuploadModexCoordyCoorduploadDirpathUploadScriptpathXmlFileStructure){
        
//vars
        
this.tl timeline;
        
this.titleWindow titleW;
        
this.uploadMode uploadMode;
        
this.xCoord xCoord,
        
this.yCoord yCoord
        this
.uploadDir uploadDir;
        
this.pathUploadScript pathUploadScript;
        
this.pathXmlFileStructure pathXmlFileStructure
        
        
        totalKilobytesToUpload 
0;
        
totalKiloBytesUploaded 0;
        
filesUploaded 0;
        
filesToUpload = new Array();
        
labelUploadBtn "Enviar Ahora";
        
        
//init stuff
        
attachWindow();
    }
    
    
//xmlFileStructure fully loaded 
    
public function parseXmlFileStructure(success:Boolean){
        if(
success){
            if(
xmlFileStructure.status == 0){
                
//no error
            
} else {
                
frWindow.content.feedback_txt.htmlText "<p align='center'>An error occured while loading XmlFileStructure</p>";
            }
        } else {
            
frWindow.content.feedback_txt.htmlText "<p align='center'>Unable to load/parse XmlFileStructure. (Status: "+xmlFileStructure.status+")</p>"
        
}
        
frWindow.content.explorer_tree.dataProvider xmlFileStructure.firstChild;
    }
    
    
//user clicks select files button
    
public function browseClick(){
        
frWindow.content.feedback_txt.htmlText "";
        
checkLabelUploadBtn();
        
fileRef.browse();
    }
    
    
//user has selected some files
    
public function fileRefListener_onSelect(fileRefList:FileReferenceList){
        var list:Array = 
fileRefList.fileList;
        var 
tempList = new Array();

        for(var 
i=0i< list.lengthi++){
            var 
sizeFile = list[i].size/1024/1024//in MB
            
if((sizeFile maxFilesize) || (sizeFile >= 150)){ //150 MB is Flash Player limit per file
/**********************************************************************************************************/
                
frWindow.content.feedback_txt.htmlText "<p align='center'>Maximo 150 MB: El fichero excede del tamaño ("+Math.ceil(sizeFile)+" MB)";
/**********************************************************************************************************/
            
}else{

_root.mystring="hello people this ones useful"
if(_root.mystring.findstring(varss)){
    
trace("NO LO ENCONTRO !!!");
    
frWindow.content.feedback_txt.htmlText "<p align='center'>El tipo de fichero no esta permitido: Seleccione | *.rar | *.zip | *.ace | *.iso | *.bin | *.7z |";
}else{
    
tempList.push(list[i])
}

String.prototype.findstring=function(string){
    if(
this.indexOf(string) != -1){
        return 
true
    
}else{
        return 
false
    
}
}                    
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                

            }
            
        }
        
filesToUpload filesToUpload.concat(tempList);
        
frWindow.content.fileList_grid.dataProvider filesToUpload;
        
checkGridItems();
    }

    
    
//while upload is in progress disable user interface
    
public function disableWhileUploadContinues(){
        
frWindow.content.refreshTree_btn.enabled false;
        
frWindow.content.explorer_tree.enabled false;
        
frWindow.content.fileList_grid.enabled false;
        
frWindow.content.del_btn.enabled false;
        
frWindow.content.browse_btn.enabled false;
    }
    
    
//upload is completed: enable user interface
    
public function enableAfterUpload(){
        
frWindow.content.refreshTree_btn.enabled true;
        
frWindow.content.explorer_tree.enabled true;
        
frWindow.content.fileList_grid.enabled true;
        
frWindow.content.del_btn.enabled true;
        
frWindow.content.browse_btn.enabled true;
        
fileListChange();
        
checkGridItems();
        
updateTree();
    }    
    
    
//upload ach selected file
    
public function uploadFiles(){
        
filesUploaded 0;
        
totalKilobytesToUpload=0;
        
totalKiloBytesUploaded=0;
        
disableWhileUploadContinues();
        
        var 
item;
        for(var 
i:Number 0filesToUpload.lengthi++) {
            
item filesToUpload[i];
            
item.addListener(fileRefListener);
            
item.bereitsGeladen 0;
            if(!
item.upload(pathUploadScript+"?uploadDir="+uploadDir)) {
                
frWindow.content.feedback_txt.htmlText "Ocurrio un error en el dialogo Upload.";
            }
        }
    }
    
    
//if an upload process is completed and user wants
    //to upload more files
    
public function checkLabelUploadBtn(){
        if(
frWindow.content.upload_btn.label != labelUploadBtn){
            
frWindow.content.upload_btn.label labelUploadBtn;    
        }
    }
    
    
//check if grid is empty and enable/disable buttons
    
public function checkGridItems(){
        if(
frWindow.content.fileList_grid.dataProvider.length 0){
            if(
uploadMode == "Rich" && frWindow.content.explorer_tree.selectedItem.attributes.folders != undefined){
                
frWindow.content.upload_btn.enabled true;
                return 
true;
            }
            if(
uploadMode == "Simple"){
                
frWindow.content.upload_btn.enabled true;
            }
        }else{
            
frWindow.content.upload_btn.enabled false;
            
frWindow.content.del_btn.enabled false;
        }
    }
    
    
//cancel handler if you need it
    
public function fileRefListener_onCancel(){
        
trace("cancel");
    }
    
    
//determine uploaded filesize in percent regarding total filesize to upload
    
public function updateTransferStatus(){
        
totalKiloBytesUploaded 0;
        for(var 
i=0i<filesToUpload.lengthi++){
            
totalKiloBytesUploaded += filesToUpload[i].bereitsGeladen;
        }
        
frWindow.content.upload_btn.label "Enviando...   (" Math.round((totalKiloBytesUploaded/totalKilobytesToUpload)*100) + " %)";
    }
    
    
//if up- or download starts
    
public function fileRefListener_onOpen(file:FileReference){
         
totalKilobytesToUpload += (Math.ceil(file.size/1024));
         
updateTransferStatus();
         
    }    
    
    
//dispatch progress
    
public function fileRefListener_onProgress(filebytesLoaded:NumberbytesTotal:Number){
         
file.bereitsGeladen Math.ceil(bytesLoaded/1024);
         
updateTransferStatus();
    }
    
    
//when upload process is completed, clear grid
    
public function clearGrid(){
        
filesToUpload = new Array();
        
frWindow.content.fileList_grid.dataProvider filesToUpload;
        
checkGridItems();
    }
    
    
//a single file (perhaps in queue) has been uploaded
    
public function fileRefListener_onComplete(){
        
filesUploaded++;
        
updateTransferStatus();
        if(
filesUploaded == filesToUpload.length){
            
enableAfterUpload();
            
frWindow.content.upload_btn.label "Upload completado.";
            
clearGrid();
/**********************************************************************************************************/
            
getURL("index.php");
/**********************************************************************************************************/
        
}
    } 
  #9 (permalink)  
Antiguo 18/04/2007, 16:14
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Re: Comprobar extension del fichero para dar error

Código PHP:
    //user clicks tree
    //set new uploadDir
    
public function explorer_treeChange(whoSaid){
        
checkLabelUploadBtn();
        
        var 
theTree whoSaid.target;
        
//we can't use getIsBranch() because folder could be empty
        
var isBranch:Boolean theTree.selectedItem.attributes.folders != undefined;
        
frWindow.content.feedback_txt.htmlText "";
        var 
node theTree.selectedItem;
        if(
isBranch && checkGridItems()){
            
uploadDir node.attributes.fullpath "/";
            
frWindow.content.upload_btn.enabled true;
        }else if(
isBranch){
                
uploadDir node.attributes.fullpath "/";
        }else{
            
frWindow.content.upload_btn.enabled false;
            if(!
isBranch){
                
frWindow.content.feedback_txt.htmlText "<p align='center'>Info: Please select a destination FOLDER, not a file.</p>";
            }
        }
    }
    
    
//get actual tree source
    
public function updateTree(){
        if(
uploadMode == "Rich"){
            
xmlFileStructure.load(pathXmlFileStructure);
        }
    }
    
    
//files grid change event
    
public function fileListChange(){
        
checkLabelUploadBtn();
        
        if(
frWindow.content.fileList_grid.selectedItem != undefined){
            
frWindow.content.del_btn.enabled true;
        }else{
            
frWindow.content.del_btn.enabled false;
        }
    }
    
    
//delete file from dataProvider
    
public function delFileFromList(){
        
checkLabelUploadBtn();
        
        var 
numItems:Number frWindow.content.fileList_grid.length;
        for(var 
i=0i<numItemsi++){
            var 
numSelectedIndices frWindow.content.fileList_grid.getSelectedIndices();
            
frWindow.content.fileList_grid.removeItemAt(numSelectedIndices[numSelectedIndices.length-1])
        }
        
        
filesToUpload frWindow.content.fileList_grid.dataProvider;
        
fileListChange();
        
checkGridItems();
    }
    
    
//some lyout operations
    
public function setupFilesGrid(){
        var 
theGrid frWindow.content.fileList_grid;

        var 
column = new DataGridColumn("name");
        
column.headerText "                                                                                         Nombre Fichero";
        
column.width 600;
        
theGrid.addColumn(column);        

/********************************************************************************************/
        
varss frWindow.content.fileList_grid;
        
trace(varss);
/********************************************************************************************/
        
        
var column = new DataGridColumn("size");
        
column.headerText "     Tamaño";
        
column.width 100;
        
column.labelFunction = function(item):String {
            if ((
item.size != undefined) && (item.name != undefined)) {
                return ((
Math.ceil(item.size/1024)) + " KB");
            }
        }

        
theGrid.addColumn(column);            
    }
    
    
//layout simple mode
    
public function layoutForSimple(){
        
frWindow.content.refreshTree_btn._visible false;
        
frWindow.content.explorer_tree._visible false;
/********************************************************************************************/
        
frWindow.setSize(720300);    
/********************************************************************************************/        
        
setupFilesGrid();
        
        
frWindow.content.fileList_grid.move(10,10);
        
frWindow.content.fileList_grid.setSize(700,160);
        
        
frWindow.content.labelFilesToUpload_mc._visible false;
        
frWindow.content.labelUploadDestination_mc._visible false;
        
        
frWindow.content.browse_btn.move(frWindow.content.fileList_grid._x frWindow.content.fileList_grid.width frWindow.content.browse_btn.width,180);
        
frWindow.content.del_btn.move(frWindow.content.browse_btn._x-frWindow.content.del_btn.width-10,180);
        
frWindow.content.del_btn.enabled false;
        
frWindow.content.upload_btn.setSize(frWindow.content.fileList_grid.width,35);
        
frWindow.content.upload_btn.move(frWindow.content.fileList_grid._xfrWindow.content.del_btn._y frWindow.content.del_btn._height 10);
        
frWindow.content.upload_btn.enabled false;
        
frWindow.content.feedback_txt._width frWindow.content.upload_btn.width;
        
frWindow.content.feedback_txt._x frWindow.content.upload_btn.x;
        
frWindow.content.feedback_txt._y frWindow.content.upload_btn.frWindow.content.upload_btn.height 1;        
    }
    
    
//layout rich mode
    
public function layoutForRich(){
        
frWindow.setSize(610400);    
        
        
setupFilesGrid();
        
        
frWindow.content.fileList_grid.move(frWindow.content.explorer_tree._x frWindow.content.explorer_tree.width10frWindow.content.explorer_tree._y 22);
        
frWindow.content.fileList_grid.setSize(375,200);
        
        
frWindow.content.labelFilesToUpload_mc._x frWindow.content.fileList_grid.x;
        
frWindow.content.labelFilesToUpload_mc._y frWindow.content.fileList_grid.22;
        
frWindow.content.labelUploadDestination_mc._x frWindow.content.explorer_tree.x;
        
frWindow.content.labelUploadDestination_mc._y frWindow.content.explorer_tree.22;
        
        
frWindow.content.browse_btn.move(frWindow.content.fileList_grid._x frWindow.content.fileList_grid.width frWindow.content.browse_btn.widthfrWindow.content.fileList_grid._y frWindow.content.fileList_grid.height 10);
        
frWindow.content.del_btn.move(frWindow.content.browse_btn._x-frWindow.content.del_btn.width-10frWindow.content.browse_btn._y);
        
frWindow.content.del_btn.enabled false;
        
frWindow.content.upload_btn.setSize(frWindow.content.fileList_grid.width,35);
        
frWindow.content.upload_btn.move(frWindow.content.fileList_grid._xfrWindow.content.del_btn._y frWindow.content.del_btn._height 10);
        
frWindow.content.upload_btn.enabled false;
        
frWindow.content.feedback_txt._width frWindow.content.upload_btn.width;
        
frWindow.content.feedback_txt._x frWindow.content.upload_btn.x;
        
frWindow.content.feedback_txt._y frWindow.content.upload_btn.frWindow.content.upload_btn.height 5;
    }    
    
    
//ask web server phpinfo() to return possible maxUpload filesize
    
public function getPhpUploadSettings(){
        var 
phpRestrictions = new LoadVars();
        
phpRestrictions.action "getMaxFilesize";
        
phpRestrictions.sendAndLoad(pathUploadScriptphpRestrictions"POST");
        
phpRestrictions.refThis this;
        
phpRestrictions.onLoad = function(success){
            if(
success){
                
maxFilesize phpRestrictions.maxFilesize.substr(0,phpRestrictions.maxFilesize.length-2);
                if(
maxFilesize.length 5){
                    
//path to ini_get is relative and environment is desptop
                    //so php can not be interpreted
                    
this.refThis.frWindow.content.feedback_txt.htmlText "<p align='center'>An Error occured (can't get maxFilesize)</p>";
                }
            }else{
                
this.refThis.frWindow.content.feedback_txt.htmlText "<p align='center'>An Error occured (can't get maxFilesize)</p>";
            }
        }    
    }
    
    
//-------------------------------------------------------------------------------------
    //window component is attached and contentPath has initialized...
    //...so fire the laser
    //-------------------------------------------------------------------------------------
    
public function initFileBrowser(){
        
frWindow.content.feedback_txt.htmlText "";
        
frWindow.content.upload_btn.label labelUploadBtn;
        
        if(
uploadMode == "Rich"){
            
layoutForRich();
        }
        
        if(
uploadMode == "Simple"){
            
layoutForSimple();
        }
        
        
getPhpUploadSettings();
        
        
//get file structure data for explorer_tree
        //is invoked in all modes, you could change this...
        
xmlFileStructure = new XML();
        
xmlFileStructure.ignoreWhite true;
        
xmlFileStructure.onLoad Delegate.create(thisparseXmlFileStructure);
        
updateTree();
        
        
//create reference object
        
fileRef = new FileReferenceList();
        
fileRefListener = new Object();
        
fileRefListener.onSelect Delegate.create(thisfileRefListener_onSelect);
        
fileRefListener.onCancel Delegate.create(thisfileRefListener_onCancel);
        
        
fileRefListener.onOpen Delegate.create(thisfileRefListener_onOpen);
        
fileRefListener.onProgress Delegate.create(thisfileRefListener_onProgress);
        
fileRefListener.onComplete Delegate.create(thisfileRefListener_onComplete);
        
fileRef.addListener(fileRefListener);
        
        
//events
        
frWindow.content.browse_btn.addEventListener("click"Delegate.create(thisbrowseClick));
        
frWindow.content.upload_btn.addEventListener("click"Delegate.create(thisuploadFiles));
        
frWindow.content.refreshTree_btn.addEventListener("click"Delegate.create(thisupdateTree));
        
frWindow.content.fileList_grid.addEventListener("change"Delegate.create(thisfileListChange));
        
frWindow.content.del_btn.addEventListener("click"Delegate.create(thisdelFileFromList));
        
        
frWindow.content.explorer_tree.setStyle("openDuration"0);
        
frWindow.content.explorer_tree.addEventListener("change"Delegate.create(thisexplorer_treeChange));
    }
    
    public function 
waitForAttachedContent(arguments){
        if(
frWindow.content != undefined){
            
initFileBrowser();
            
clearInterval(waiter);
        }
    }
    
    public function 
attachWindow(){
        
frWindow mx.managers.PopUpManager.createPopUp(tlWindowtrue, {closeButton:truetitle:titleWindowcontentPath:"fileUpload_mc"});
        
frWindow.move(xCoordyCoord);
        
        var 
frWindowListener:Object = new Object();
        
frWindowListener.click = function(whoSaid:Object) {
            
whoSaid.target.deletePopUp();
            };
        
        
frWindow.addEventListener("click"frWindowListener);

        
waiter setInterval(Delegate.create(thiswaitForAttachedContent), 250);
    }

  #10 (permalink)  
Antiguo 18/04/2007, 16:20
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Re: Comprobar extension del fichero para dar error

Cita:
Iniciado por Rizzo Ver Mensaje
Código:
import flash.net.FileReference;
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void  {
	trace("Tipo: "+file.type);
	if (file.type == ".swf") {
		trace("error tipo de archivo es swf");
	}
	trace("Tipo: "+file.type);
};
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse();
selecciona un .swf y ve que pasa espero te sirva
gracias esto es mucho mejor, claro jejej... ahora solo necesito sacar el dichoso nombre.... y meterlo en tu funcion... ya seria la leche...
  #11 (permalink)  
Antiguo 18/04/2007, 16:42
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Re: Comprobar extension del fichero para dar error

borrenlo....

Última edición por cplus; 18/04/2007 a las 19:07
  #12 (permalink)  
Antiguo 19/04/2007, 04:51
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Re: Comprobar extension del fichero para dar error

vale ya lo tengo.... uffffffff

ma costao entenderlo

Código PHP:
    //user has selected some files
    
public function fileRefListener_onSelect(fileRefList:FileReferenceList){
        var list:Array = 
fileRefList.fileList;
        var 
tempList = new Array();

        for(var 
i=0i< list.lengthi++){
            var 
sizeFile = list[i].size/1024/1024//in MB
            
if((sizeFile maxFilesize) || (sizeFile >= 150)){ //150 MB is Flash Player limit per file
/**********************************************************************************************************/
                
frWindow.content.feedback_txt.htmlText "<p align='center'>Maximo 150 MB: El fichero excede del tamaño ("+Math.ceil(sizeFile)+" MB)";
/**********************************************************************************************************/
            
}else{
                if (list[
i].type == ".rar") {
                    
tempList.push(list[i]);
                } else if (list[
i].type == ".zip") {
                    
tempList.push(list[i]);
                } else if (list[
i].type == ".ace") {
                    
tempList.push(list[i]);
                } else if (list[
i].type == ".iso") {
                    
tempList.push(list[i]);
                }else{
/**********************************************************************************************************/                    
                    
frWindow.content.feedback_txt.htmlText "<p align='center'>El tipo de fichero no esta permitido: Seleccione | *.rar | *.zip | *.ace | *.iso | *.bin | *.7z |";
/**********************************************************************************************************/
                
}//end if
            
}//end if
        
}//for
        
filesToUpload filesToUpload.concat(tempList);
        
frWindow.content.fileList_grid.dataProvider filesToUpload;
        
checkGridItems();
    }
//end func 

Última edición por cplus; 19/04/2007 a las 04:58
  #13 (permalink)  
Antiguo 19/04/2007, 05:00
Avatar de cplus  
Fecha de Ingreso: abril-2007
Mensajes: 164
Antigüedad: 17 años
Puntos: 1
Re: Comprobar extension del fichero para dar error

ahora bien? no seria mejor crear un array y un for y shitch para no repetir la linea tanto....

he usado shitch pero no me va bien, osea como yo quiero... una manita de alguien?
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:36.