Author: michiel
Date: 2010-02-11 21:38:23 +0100 (Thu, 11 Feb 2010)
New Revision: 40971

Modified:
   mmbase/trunk/base-webapp/src/main/webapp/mmbase/upload/MMUpload.js.jsp
   mmbase/trunk/base-webapp/src/main/webapp/mmbase/upload/upload.body.jspx
Log:


Modified: mmbase/trunk/base-webapp/src/main/webapp/mmbase/upload/MMUpload.js.jsp
===================================================================
--- mmbase/trunk/base-webapp/src/main/webapp/mmbase/upload/MMUpload.js.jsp      
2010-02-11 20:32:54 UTC (rev 40970)
+++ mmbase/trunk/base-webapp/src/main/webapp/mmbase/upload/MMUpload.js.jsp      
2010-02-11 20:38:23 UTC (rev 40971)
@@ -12,6 +12,7 @@
     this.statusElement = null;
     this.uid = "";
     this.transaction = null;
+    this.validator = null;
 }
 
 
@@ -44,11 +45,14 @@
  * Given an input[type=file], returns the node number which is represented in 
it.
  */
 MMUploader.prototype.getNodeForInput  = function(input) {
-    var classes = $(input).attr("class").split(' ');
-    for (var i in classes) {
-        var cl = classes[i];
-        if (cl.indexOf("mm_n_") == 0) {
-            return cl.substring("mm_n_".length);
+    var classesString = $(input).attr("class");
+    if (classesString != null) {
+        var classes = classesString.split(' ');
+        for (var i in classes) {
+            var cl = classes[i];
+            if (cl.indexOf("mm_n_") == 0) {
+                return cl.substring("mm_n_".length);
+            }
         }
     }
     return null;
@@ -62,9 +66,22 @@
         return;
     }
 
+    var fileItem = $("#" + fileid);
+    if (fileItem.length == 0) {
+        console.log("No fileitem " + fileid);
+        return;
+    }
+    if (fileItem[0].type != 'file') {
+        // not a fileitem
+        return;
+    }
+    if (fileItem.val().length == 0) {
+        // no file selected;
+        return;
+    }
+
     self.uploading[fileid] = true;
     self.uploadingSize++;
-    var fileItem = $("#" + fileid);
 
     // Remember event-handlers.
     var events = fileItem.data('events');
@@ -76,7 +93,12 @@
             setTimeout(progress, 1000);
         }
     };
-    progress();
+    //progress();
+    if (self.validator != null) {
+        self.validator.removeValidationFromElement(fileItem[0]);
+    } else {
+        //console.log("Validator not set");
+    }
 
     $.ajaxFileUpload ({
             url: "${mm:link('/mmbase/upload/upload.jspx')}" + "?uid=" + 
self.uid + "&name=" + fileItem.attr("name") + "&n=" + node + "&transaction=" + 
self.transaction,
@@ -104,13 +126,18 @@
                             name = "MMU_" + name;
                             $(fileItem).attr("name", name);
                         }
+
                         // Rebind  event handlers:
                         for (var event in events) {
                             for (var key in events[event]) {
                                 $(fileItem).bind(event, events[event][key]);
                             }
                         }
+                        if (self.validator != null) {
+                            self.validator.addValidationForElements(fileItem);
+                        }
 
+
                     } catch (e) {
                         alert(e);
                     }

Modified: 
mmbase/trunk/base-webapp/src/main/webapp/mmbase/upload/upload.body.jspx
===================================================================
--- mmbase/trunk/base-webapp/src/main/webapp/mmbase/upload/upload.body.jspx     
2010-02-11 20:32:54 UTC (rev 40970)
+++ mmbase/trunk/base-webapp/src/main/webapp/mmbase/upload/upload.body.jspx     
2010-02-11 20:38:23 UTC (rev 40971)
@@ -15,7 +15,7 @@
     if (uid.length() > 0) {
       uid = "." + uid;
     }
-    File f  = new File(dir, cloud.getUser().getIdentifier() + uid + "." + name 
+ "." + is.getName());
+    File f  = new File(dir, cloud.getUser().getIdentifier() + uid + "." + n + 
"." + name + "." + is.getName());
     FileServlet.protectFile((HttpServletRequest) pageContext.getRequest(), f);
     OutputStream o = new FileOutputStream(f);
     org.mmbase.util.IOUtil.copy(is, o);

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to