Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/10/2007, 13:26
eybel
 
Fecha de Ingreso: marzo-2007
Mensajes: 782
Antigüedad: 17 años, 1 mes
Puntos: 16
como borrar archivo con FileReference, DataGrid y php

Bueno mi codigo quedo asi, hasta el momento en el que le quiero agregar una funcion mas, la de mandar un nombre de archivo extraido de una DataGird donde es alimentado de informacion con un php...que hace una lista...

Quiero con un boton "borrar" mandar el archivo seleccionado del DataGrid, para que el php lo borre del servidor...

Como hago esto???

Mi codigo es asi:

Cita:
import flash.net.FileReference;
var fileUpload:FileReference = new FileReference();
var path:String = "http://www.web.com/files"
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;*.JPG;*.JPEG", 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._visible = false;
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.barra_mc._visible = true;
load_mc.label_txt.text = porcentaje+"% del archivo "+archivo.name;
load_mc.barra_mc.gotoAndStop(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+"/uploads/"+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();
Y el php es asi:

Cita:
<?
print "fichero_borrado=".( ( unlink ( $_POST ['fichero'] ) ) ? "si" : "no" ) . "&fin=si";
?>
Ya esta funcionando el UPLOAD y DOWNLOAD aqui...pero el boton borrar todavia no...