Aurigma Forums
»
Legacy Products
»
Archive
»
Image Uploader
»
Using BeforeUpload Listener with other properties in FireFox
Rank: Member
Groups: Member
Joined: 4/19/2007(UTC) Posts: 9
|
here is the scenerio.
I have a listener set on the BeforeUpload which will validate the form sent with the upload form. this worked great, if the form wasn't valid it would cancel the uplaod by returning false to BeforeUpload Even.
i tested in IE.7 and FireFox 2.0.0.11 - so far so good.
next i wanted to make sure that the descriptions for the files are not null, so:
i used getUploadFileCount to get the number of files. this worked i used getUploadFileName to get the name it returns null i used getUploadFileDescription it returns null
now this is annoying as it is, that there are returning null (any ideas why?) but here's the rub, if i touch getUploadFileName in anyway, it seems to negate the BeforeUpload listener. so even thought that listener returns false, the upload still proceeds.
Two Q's: 1. why are those properties returning null? 2. why is the event listener no longer accepting return value when the filename property is touched?
thanks
|
|
|
|
Rank: Advanced Member
Groups: Joined: 8/3/2003(UTC) Posts: 998
|
Hello,
Did you use zero or one-based indexes in getUploadFileName etc. methods? Note that the indexes are one-based. |
|
|
|
|
Rank: Member
Groups: Member
Joined: 4/19/2007(UTC) Posts: 9
|
that would be 1 based. Please note that it works fine for IE so the basics have been covered. else it would not work there either. Thank you Alex Makhov wrote:Hello,
Did you use zero or one-based indexes in getUploadFileName etc. methods? Note that the indexes are one-based.
|
|
|
|
Rank: Advanced Member
Groups: Joined: 8/3/2003(UTC) Posts: 998
|
Hello,
OK, that was the simplest possible reason of the problem. Could you show your code or better give me the link to your problem page as a PM? |
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 1/15/2008(UTC) Posts: 3
|
here is the relevent code Code:// 1/11/2008:8:43 AM
function Validate_Descriptions(){
var FilesNeedingDescriptions = new Array()
var r = "";
try{
var ui = getImageUploader("ImageUploader")
} catch(e){
return(Validate_HTMLDescriptions())
}
try {
if(ui){
if(ns){return("");}
var fileCount = ui.getUploadFileCount();
var i = 0;
var ii = 0;
var arrFileName
var fileName, fileDesc;
for(i=1;i<=fileCount;i++){
fileName = ui.getUploadFileName(i);
if(fileName!=null){
arrFileName = fileName.toLowerCase().split("\\");
fileName = arrFileName[arrFileName.length-1];
}
fileDesc = ui.getUploadFileDescription(i);
FilesNeedingDescriptions[FilesNeedingDescriptions.length] = {
filename : fileName,
description: fileDesc,
index : i
};
}
return(Validate_FileList(FilesNeedingDescriptions));
}
} catch(e){return("");}
return("");
}
Alex Makhov wrote:Hello,
OK, that was the simplest possible reason of the problem. Could you show your code or better give me the link to your problem page as a PM? Edited by user Tuesday, January 15, 2008 1:46:41 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Joined: 7/26/2006(UTC) Posts: 203
|
Hello, I have checked the part of your code and it workes perfectly: Code:
iu.addEventListener("BeforeUpload", "__BeforeUpload");
...
function __BeforeUpload()
{
var iu = getImageUploader("ImageUploader1")
if(iu)
{
var fileCount = iu.getUploadFileCount();
for(i = 1; i <= fileCount; i++)
{
fileName = iu.getUploadFileName(i);
fileDesc = iu.getUploadFileDescription(i);
alert(fileName);
alert(fileDesc);
}
}
}
Probably the problem is in eror handling: Code:
try{
var ui = getImageUploader("ImageUploader")
} catch(e){
return(Validate_HTMLDescriptions())
}
Try something like it: Code:
function Validate_Descriptions(){
var FilesNeedingDescriptions = new Array()
var r = "";
var ui = getImageUploader("ImageUploader")
try {
if(ui){
if(ns){return("");}
.....
}
Edited by user Monday, February 25, 2008 3:59:54 PM(UTC)
| Reason: Not specified |
Best regards, George Ulyanov
|
|
|
|
Aurigma Forums
»
Legacy Products
»
Archive
»
Image Uploader
»
Using BeforeUpload Listener with other properties in FireFox
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.