Forum Clubic

Upload en flash + php

Slt voila je voudrais savoir s il etait possible apres l upload des fichiers , envoyer une requete sur une page php avec les noms de fichier uploader

Merci pour vos reponses


//Allow this domain
System.security.allowDomain("http://localhost/");
import flash.net.FileReferenceList;
import flash.net.FileReference;
import mx.transitions.Tween;
import mx.transitions.easing.*;
// The listener object listens for FileReference events.
var listener:Object = new Object();
//space left for this user (will be set in php file)
//spaceTotal = 10485760;
//10 MB
//spaceLeft = 5242880;
//5 MB
filesizeErrorText = "Can't upload because the size of the selected files is too big.";
uploadErrorText = "Something went wrong while uploading. Please try again later.";
spaceTotal = 10485760;
spaceUsed = 3242880;
spaceLeft = spaceTotal-spaceUsed;
totalFileSize = 0;
fileTypes = new Array({description:"Any", extension:"*.*"},{description:"Images only", extension:"*.jpg;*.gif"})
//
upwin._visible = false;
upwin._alpha = 0;
upwin.alphaTo = 0;
upwin.percentagebar._width = 0;
space_selected._width = 0;
space_used._width = 0;
tableDetails = new Array();
fileBox.dataProvider = tableDetails;
//Style the DataGrid object
fileBox.setStyle("alternatingRowColors",[0xF9FCFD,0xFFFFFF]);
fileBox.setStyle("fontFamily","Arial");
fileBox.setStyle("rollOverColor",0xE0EAF3);
fileBox.setStyle("selectionColor",0xC0D5E9);
fileBox.setStyle("vGridLines",false);
browseBtn.setStyle("themeColor", "haloOrange");
clearBtn.setStyle("themeColor", "haloOrange");
deleteBtn.setStyle("themeColor", "haloOrange");
uploadBtn.setStyle("themeColor", "haloOrange");
//
uploadBtn.enabled = false;
// When the user selects a file, the onSelect() method is called, and
// passed a reference to the FileReference object.
listener.onSelect = function(selectedFiles:FileReferenceList):Void {
uploadBtn.enabled = false;
totalFileSize = 0;

oldTableDetails = tableDetails;
tableDetails = new Array();

allImages.fileList = allImages.fileList.concat(selectedFiles.fileList);

for (i in allImages.fileList) {
tableDetails.unshift({ID:i, Naam:allImages.fileList[i].name});
totalFileSize += allImages.fileList[i].size;
}
//check if files are small enough
if (totalFileSize>spaceLeft) {
errorField.text = filesizeErrorText;
}else{
uploadBtn.enabled = true;
}
fileBox.dataProvider = tableDetails;
fileBox.getColumnAt(0).width = 40;
drawGraph();
};
function drawGraph() {
//draw the percentageBar
space_used._width = spaceUsed/spaceTotal*290;
space_selected._width = (spaceUsed+totalFileSize)/spaceTotal*290;
}
drawGraph();
var imageFiles:FileReferenceList = new FileReferenceList();
var allImages:FileReferenceList = new FileReferenceList();
imageFiles.addListener(listener);
browseBtn.onPress = browseImages;
clearBtn.onPress = function() {
tableDetails = new Array();
allImages.fileList = new Array();
fileBox.dataProvider = tableDetails;
totalFileSize = 0;
drawGraph();
};
deleteBtn.onPress = function() {
/*for( k in tableDetails){
trace(tableDetails[k].Naam);
}
for( l in allImages.fileList){
trace(allImages.fileList[l].name);
}
*/
for (a in fileBox.selectedItems) {
id=fileBox.selectedItems[a].ID;
for(b in tableDetails){
if(tableDetails[b].ID == id){
ak = tableDetails.slice(0, b).concat(tableDetails.slice(b+1));
}
}
allImages.fileList = allImages.fileList.slice(0, id).concat(allImages.fileList.slice(id+1));

tableDetails = ak;
}
totalFileSize = 0;
for (i in allImages.fileList) {
totalFileSize += allImages.fileList[i].size;
}
drawGraph();
fileBox.dataProvider = tableDetails;
};
uploadBtn.onPress = uploadImages;
// Call the browseImages() function, opens a file browser dialog.
function browseImages(event:Object):Void {
imageFiles.browse(fileTypes);
}
function uploadImages() {
upwin.alphaTo = 100;
browseBtn.enabled = false;
totalErrors = 0;
totalBytesLoaded = 0;
previousBytesLoaded = 0;
for (i in tableDetails) {
allImages.fileList[i].upload('upload.php');
listener[i] = new Object();
listener[i].previousBytesLoaded = 0;
///
listener[i].onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
newBytesLoaded = bytesLoaded-this.previousBytesLoaded;
totalBytesLoaded += newBytesLoaded;
percentage = Math.round(totalBytesLoaded/totalFileSize*100);
a = 2.9*percentage;
upwin.pw = a;
if (percentage == 100) {
setInterval(nextPage,1000);
}
this.previousBytesLoaded = bytesLoaded;
};
//Possible file upload errors
listener[i].onHTTPError = function(file:FileReference, httpError:Number):Void {
file.cancel();
totalErrors += 1;
};
listener[i].onIOError = function(file:FileReference):Void {
file.cancel();
totalErrors += 1;
};
listener[i].onSecurityError = function(file:FileReference, errorString:String):Void {
file.cancel();
totalErrors += 1;
};
if(totalErrors > 0){
upwin.alphaTo = 0;
errorField.text = uploadErrorText;
}
///
allImages.fileList[i].addListener(listener[i]);



}
}


Edité le 16/05/2010 à 20:14

[quote=“Startide”]
Let Me Google That For You[/Quote]
tinyurl.com…

Si tu veut faire un upload en flash avec traitement php derrière, je te conseille d’utilise la librairie uplodify. ( www.uploadify.com… ). C’est un plugin pour Jquery ( javascript ), et cela te permet de faire des upload multiple en restant toujours sur la même page, et d’effectuer un traitement php via ajax.

Tu peut même configurer chaque état de l’upload, pour faire par exemple une preview du fichier uploadé. Et tu peut aussi forcer le navigateur à ne reconnaitre que certain type de fichier. L’installation est assez facile, car cela remplace n’importe quel champ de fichier par l’uploader en flash.