Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Bob_J  
#1 Posted : Friday, July 14, 2006 3:57:11 AM(UTC)
Bob_J

Rank: Member

Groups: Member
Joined: 3/20/2006(UTC)
Posts: 30

I want to make it so that the person uploading is forced to an exact number of uploads, 5. No more, no less.

Obviously, I can use MaxFileCount to limit the maximum number to 5. But how do I force the user to no less than 5? (Incidentally, sure would be nice if you guys would implement MinFileCount as a future feature).

I was thinking that I could ImageUploader_BeforeUpload() in combination with getUploadFileCount() to check how many files the user has selected for upload, and pop an alert message if it's less than 5. But if the amount is less than 5, how do I stop the upload from starting?
Bob_J  
#2 Posted : Friday, July 14, 2006 4:03:37 AM(UTC)
Bob_J

Rank: Member

Groups: Member
Joined: 3/20/2006(UTC)
Posts: 30

Incidentally, I tried the following, and it does not stop the upload:

Code:
function ImageUploader_BeforeUpload()
{
	var numSelected = getImageUploader("ImageUploader").getUploadFileCount();
	if(numSelected < 5)
	{
		alert("You must select exactly 5 images before hitting send.");
		getImageUploader("ImageUploader").Stop();
	}
}

Edited by user Monday, February 18, 2008 6:01:04 PM(UTC)  | Reason: Not specified

Fedor  
#3 Posted : Friday, July 14, 2006 4:11:02 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,537

Thanks: 4 times
Was thanked: 56 time(s) in 55 post(s)
Bob,

Just use external custom buttons and don't call Send method until meet the criteria. In short here is pseudocode:
Code:
<script type="text/javascript">
function Upload_click() {
  if (getImageUploader('ImageUploader').getUploadFileCount()==5) {
    getImageUploader('ImageUploader').Send();
  }
  else {
    alert("You should select exactly 5 files.");
  }
}
</script>

<input type="button" value="Upload" onclick="Upload_click();">

<!--...ImageUploaderWriter code...-->


You can also handle UploadFileCountChange event and enable upload button only when user selects the required file count.

Edited by user Wednesday, October 29, 2008 12:45:35 PM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
Bob_J  
#4 Posted : Friday, July 14, 2006 4:30:18 AM(UTC)
Bob_J

Rank: Member

Groups: Member
Joined: 3/20/2006(UTC)
Posts: 30

So if I use a custom button, it would be located outside the uploader, rather than along the top of the uploader? i.e. in a different place than the current Send button? That really isn't ideal.

I prefer your second suggestion. How do I disable and enable the Send button? Am reading through the docs, but not finding it so far...
Bob_J  
#5 Posted : Friday, July 14, 2006 5:13:45 AM(UTC)
Bob_J

Rank: Member

Groups: Member
Joined: 3/20/2006(UTC)
Posts: 30

This is very frustrating. I can see the following in the "Customizing Buttons" help page:

"When no images are selected for upload, it makes sense to disable the Send button. To check if Image Uploader has anything to send, use the property named UploadFileCount in the event UploadFileCountChange. If UploadFileCount is 0, you should disable the button, otherwise - enable it."

But there's no example of HOW to do it. Am getting ready to tear my hair out.
Fedor  
#6 Posted : Friday, July 14, 2006 2:35:25 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,537

Thanks: 4 times
Was thanked: 56 time(s) in 55 post(s)
Quote:
So if I use a custom button, it would be located outside the uploader, rather than along the top of the uploader? i.e. in a different place than the current Send button? That really isn't ideal.


You can place custom buttons in top of Image Uploader, so it will look almost totally the same as native buttons.
Best regards,
Fedor Skvortsov
Fedor  
#7 Posted : Friday, July 14, 2006 2:43:37 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,537

Thanks: 4 times
Was thanked: 56 time(s) in 55 post(s)
Quote:
"When no images are selected for upload, it makes sense to disable the Send button. To check if Image Uploader has anything to send, use the property named UploadFileCount in the event UploadFileCountChange. If UploadFileCount is 0, you should disable the button, otherwise - enable it."

But there's no example of HOW to do it. Am getting ready to tear my hair out.

The code is very simple:
Code:
<script type="text/javascript" src="iuembed.js"></script>

<input id="UploadButton" type="button" value="Upload" onclick="getImageUploader('ImageUploader').Send();">

<script type="text/javascript">
function ImageUploaderID_UploadFileCountChange() {

	document.getElementById('UploadButton').disabled = (getImageUploader('ImageUploader').getUploadFileCount() != 5);

}
var iu = new ImageUploaderWriter("ImageUploaderID", 610, 500);
//...params...
//...other event listeners...
iu.addEventListener("UploadFileCountChange", "ImageUploaderID_UploadFileCountChange");
//...other event listeners...
iu.writeHtml();
</script>

Edited by user Monday, February 18, 2008 6:03:27 PM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
Users browsing this topic
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.