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

Notification

Icon
Error

Options
Go to last post Go to first unread
vyvee  
#1 Posted : Monday, May 9, 2005 10:37:00 AM(UTC)
vyvee

Rank: Member

Groups: Member
Joined: 6/27/2004(UTC)
Posts: 11

I would like to implement the removal of some images from the upload list before uploading. Basically, before uploading, I would like to go through the dimensions of each image, and remove the images that do not satisfy certain criteria. I'm able to access the properties of each image via UploadItems, but I fail to remove any of them with the Remove() method as documented. If I did so, IE6 will crash. :'( Does anybody has any luck doing this successfully? The built-in checking like MinImageWidth, MaxImageHeight are not sufficient for our purpose.
Fedor  
#2 Posted : Tuesday, May 10, 2005 11:20:00 AM(UTC)
Fedor

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 59 time(s) in 58 post(s)
Hello, Could you post your code which cause IE craching? I just checked again Remove method and it works perfectly.
Best regards, Fedor Skvortsov
Alex Makhov  
#3 Posted : Tuesday, May 10, 2005 11:51:00 AM(UTC)
Alex Makhov

Rank: Advanced Member

Groups: Member
Joined: 8/3/2003(UTC)
Posts: 998

Hi, When the BeforeUpload and Progress event are fired all items to be uploaded are already in the Upload list. You can't remove them in this moment. We will fix the problem with IE crash, but it wouldn't fix your problem. As a decision we recommend you to use UploadFileCountChange event to remove "bad" items from the Upload list right after adding them.
Sincerely yours, Alex Makhov UserPostedImage Follow Aurigma on Twitter!
vyvee  
#4 Posted : Tuesday, May 10, 2005 4:03:00 PM(UTC)
vyvee

Rank: Member

Groups: Member
Joined: 6/27/2004(UTC)
Posts: 11

Hi, Thanks for the reply. I just found what would trigger the bug: if the Layout is TwoPanes then IE will crash once I've done one or two operations Removal(). Conceptually, Removal() should deselect an image, but in TwoPanes layout it will (incorrectly) remove the image from the right panel. Or, is there any function that is able to deselect an image in TwoPanes layout? Here's the HTML code used in the testing:
Code:
<html>
  <head></head>
  <body>

<object type="application/x-oleobject" id="ImageUploader" name="ImageUploader"
   classid="clsid:A18962F6-E6ED-40B1-97C9-1FB36F38BFA8"
   CodeBase="/ImageUploader3.cab#version=3,5,46,0" width="600" height="350">
  <param name="Action" value="/dev.php">
  <param name="Layout" value="TwoPanes">
</object>

<script for="ImageUploader" event="UploadFileCountChange()">
for (i=ImageUploader.UploadItems.Count; i>=1; i--) {
  var uploadItem = ImageUploader.UploadItems.Item(i);
  if (uploadItem.Width < 500) {
    alert(uploadItem.FileName + ': width has to be >= 500');
    ImageUploader.UploadItems.Remove(i);
  }
}
</script>

  </body>
</html>
======================================================== 02/14/2008, Fedor This code snippet is out of date. See the sample bellow for actual code. ========================================================

Edited by user Thursday, February 14, 2008 6:48:47 PM(UTC)  | Reason: Not specified

Fedor  
#5 Posted : Tuesday, May 10, 2005 4:18:00 PM(UTC)
Fedor

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 59 time(s) in 58 post(s)
We confirm the problem. It will be fixed in next service release. If you want to receive update before next official service release, then please submit case.

Edited by user Friday, May 23, 2008 2:58:39 PM(UTC)  | Reason: Not specified

Best regards, Fedor Skvortsov
Alex Makhov  
#6 Posted : Tuesday, May 10, 2005 7:51:00 PM(UTC)
Alex Makhov

Rank: Advanced Member

Groups: Member
Joined: 8/3/2003(UTC)
Posts: 998

Hi, The issue with wrong Remove method is resolved and will be available in next ImageUploader release. As about your sample. I think, it needs a little modification:
Code:
<script for="ImageUploader" event="UploadFileCountChange()">

for (i=ImageUploader.UploadItems.Count; i>=1; i--) {
  var uploadItem = ImageUploader.UploadItems.Item(i);
  if (uploadItem.Width < 500) {
    alert(uploadItem.FileName + ': width has to be >= 500');
    ImageUploader.UploadItems.Remove(i);
    i--;//  decrement indexer value to avoid double checks
  }
}

</script>
======================================================== 02/14/2008, Fedor This topic is out of date. You should use iuembed.js syntax now. Also please note that you should use plain upload item API (UploadFileXXX methods) instead of UploadItems property.
Code:
<script type="text/javascript" src="iuembed.js"></script>
<script type="text/javascript">
function ImageUploaderID_UploadFileCountChange() {

	var upl = getImageUploader("ImageUploaderID");

	for (var i = upl.getUploadFileCount(); i >= 1; i--) {
		if (upl.getUploadFileWidth(i) < 500) {
			alert(upl.getUploadFileName(i) + ': width has to be >= 500');
			upl.UploadFileRemove(i);
			i--;//  decrement indexer value to avoid double checks
		}
	}
}
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 Wednesday, October 29, 2008 1:44:42 PM(UTC)  | Reason: Not specified

Sincerely yours, Alex Makhov UserPostedImage Follow Aurigma on Twitter!
Fedor  
#7 Posted : Tuesday, May 10, 2005 11:50:00 PM(UTC)
Fedor

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 59 time(s) in 58 post(s)
Hi, I have sent you update with bug fix.
Best regards, Fedor Skvortsov
vyvee  
#8 Posted : Wednesday, May 11, 2005 3:10:00 PM(UTC)
vyvee

Rank: Member

Groups: Member
Joined: 6/27/2004(UTC)
Posts: 11

Thanks for the efficient work! I have downloaded & tested the fixed version. It works perfectly. By the way, Alex has suggested some fix to avoid double checks. I've considred the performance issue during coding. I observe the following properties of the UploadFileCountChange() event: 1) The uploaded file will be included into the upload list one by one (internally), and the event will be fired for each file. Say, you've selected 6 files (not yet checked), and you click a tickbox to check all 6 files. In this case, the event will be fired for 6 times (each for every file added) instead of once (once for all 6 files). 2) The new file added can sit at any position in the UploadItems property, depending on the sequence the files were selected. Based on this I've modified the code as follows:
Code:
<script for="ImageUploader" event="UploadFileCountChange()">
for (var i=1; i<=ImageUploader.UploadItems.Count; i++) {
  var uploadItem = ImageUploader.UploadItems.Item(i);
  if (uploadItem.Width < 500) {
    alert(uploadItem.FileName + ': width has to be >= 500');
    ImageUploader.UploadItems.Remove(i);
    break;
  }
}
</script>
I can safely put a 'break' (instead of 'i--;' or leaving it empty) there because the event will be fired again for the next file. So 'break' should typically be able save more time than using 'i--'. Since the newly added file can be in any position in the UploadItems, we need to use a for() loop to iterate all the files in the upload list just to have a check on the newly added file. This bring up a performance issue. Suppose that I want to select 100 images. In the worst case, all images are accepted, and in this case the for() loop will be iterated for 1+2+3+...+100=5050 times! In the best case, all images are rejected, and the iteration runs for 1+1+1+...+1=100 times. Is there any way I can reduce the iteration time with the current ImageUploader interface?

Edited by user Monday, December 24, 2007 3:20:01 PM(UTC)  | Reason: Not specified

Alex Makhov  
#9 Posted : Thursday, May 12, 2005 12:22:00 PM(UTC)
Alex Makhov

Rank: Advanced Member

Groups: Member
Joined: 8/3/2003(UTC)
Posts: 998

Hi, I can safely put a 'break' (instead of 'i--;' or leaving it empty) there because the event will be fired again for the next file Yes, you are right in your case. But UploadFileCountChange event doesn't always fired for each item. For example in three panes mode when user drags files to upload pane UploadFileCountChange event is fired only once. You have to take it into account while making UploadFileCountChange event handlers.
Sincerely yours, Alex Makhov UserPostedImage Follow Aurigma on Twitter!
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.