Hi!
I’m going crazy studying some code to modify a multiple file uploader made in flash, basically, I want to pass a variable to the php file which manages the files to the server, already have prepaired the php file to receive the variable, but i can’t get to pass it through the query string to it:
Actionscript code:
[code]
function drawGraph()
{
space_used._width = spaceUsed / spaceTotal * 290;
space_selected._width = (spaceUsed + totalFileSize) / spaceTotal * 290;
}
function browseImages(event)
{
imageFiles.browse(fileTypes);
}
function uploadImages()
{
upwin.alphaTo = 100;
browseBtn.enabled = false;
totalErrors = 0;
totalBytesLoaded = 0;
previousBytesLoaded = 0;
for (i in tableDetails)
{
[B][COLOR=Red]var imageid = _root.imageid;[/COLOR][/B]
//tried this “allImages.fileList[i].upload(“upload.php?imageid=”+imageid);”
allImages.fileList[i].upload(“[COLOR=Red][B]upload.php[/B][/COLOR]”);
listener[i] = new Object();
listener[i].previousBytesLoaded = 0;
listener[i].onProgress = function (file, bytesLoaded, bytesTotal)
{
newBytesLoaded = bytesLoaded – this.previousBytesLoaded;
totalBytesLoaded = totalBytesLoaded + newBytesLoaded;
percentage = Math.round(totalBytesLoaded / totalFileSize * 100);
a = 2.9 * percentage;
upwin.pw = a;
if (percentage == 100)
{
setInterval(nextPage, 1000);
}
this.previousBytesLoaded = bytesLoaded;
}
;
listener[i].onHTTPError = function (file, httpError)
{
file.cancel();
totalErrors = totalErrors + 1;
}
;
listener[i].onIOError = function (file)
{
file.cancel();
totalErrors = totalErrors + 1;
}
;
listener[i].onSecurityError = function (file, errorString)
{
file.cancel();
totalErrors = totalErrors + 1;
}
;
if (totalErrors > 0)
{
upwin.alphaTo = 0;
errorField.text = uploadErrorText;
}
allImages.fileList[i].addListener(listener[i]);
}
}
function nextPage()
{
errorField.text = “Archivos Cargados!!!”;
}
System.security.allowDomain(“http://localhost/”);
var listener = new Object();
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;
fileBox.setStyle(“alternatingRowColors”, [16383229, 16777215]);
fileBox.setStyle(“fontFamily”, “Arial”);
fileBox.setStyle(“rollOverColor”, 14740211);
fileBox.setStyle(“selectionColor”, 12637673);
fileBox.setStyle(“vGridLines”, false);
browseBtn.setStyle(“themeColor”, “haloOrange”);
clearBtn.setStyle(“themeColor”, “haloOrange”);
deleteBtn.setStyle(“themeColor”, “haloOrange”);
uploadBtn.setStyle(“themeColor”, “haloOrange”);
uploadBtn.enabled = false;
listener.onSelect = function (selectedFiles)
{
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 = totalFileSize + allImages.fileList[i].size;
}
if (totalFileSize > spaceLeft)
{
errorField.text = filesizeErrorText;
}
else
{
uploadBtn.enabled = true;
}
fileBox.dataProvider = tableDetails;
fileBox.getColumnAt(0).width = 40;
drawGraph();
}
;
drawGraph();
var imageFiles = new flash.net.FileReferenceList();
var allImages = new flash.net.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 (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));
}
}
var imageid = _root.imageid;
allImages.fileList = allImages.fileList.slice(0, id).concat(allImages.fileList.slice(id + 1));
tableDetails = ak;
}
totalFileSize = 0;
for (i in allImages.fileList)
{
totalFileSize = totalFileSize + allImages.fileList[i].size;
}
drawGraph();
fileBox.dataProvider = tableDetails;
}
;
uploadBtn.onPress = uploadImages;