Missing files when uploading

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • MrKnife
    Private

    • Jun 2008
    • 1

    Missing files when uploading

    Hi,

    I have a script for uploading files, 3 at maximun, the problem is that when i submit only the first file is submitted the other 2 are lost, but this only happens in mozilla in IE all 3 are uploaded. Can anyone help me? This is the JS that i use:


    function MultiSelector( list_target, max ){

    // Where to write the list
    this.list_target = list_target;
    // How many elements?
    this.count = 0;
    // How many elements?
    this.id = 0;
    // Is there a maximum?
    if( max ){
    this.max = max;
    } else {
    this.max = -1;
    };

    /**
    * Add a new file input element
    */
    this.addElement = function( element){

    // Make sure it's a file input element
    if( element.tagName == 'INPUT' && element.type == 'file' ){

    // Element name -- what number am I?
    element.name = 'file_' + this.id++;

    // Add reference to this object
    element.multi_selector = this;

    // What to do when a file is selected
    element.onchange = function(){
    Filename = element.value;
    Extension = (Filename.substring(Filename.lastIndexOf("."))).to LowerCase();
    Flag = false;
    for (var i = 0; i < AllowedExtensionFile.length; i++) {
    if (AllowedExtensionFile[i] == Extension) {
    Flag = true;
    break;
    }
    }
    if (!Flag) {
    alert(MessageInvalidExtension);//This message is in the UpdloadPhotos View
    return 0;
    }
    // New file input
    var new_element = document.createElement( 'input' );
    new_element.type = 'file';

    // Add new element
    this.parentNode.insertBefore( new_element, this );

    // Apply 'update' to element
    this.multi_selector.addElement( new_element );

    // Update list
    this.multi_selector.addListRow( this );

    // Hide this: we can't use display:none because Safari doesn't like it
    this.style.position = 'absolute';
    this.style.left = '-1000px';

    };
    // If we've reached maximum number, disable input element
    if( this.max != -1 && this.count >= this.max ){
    element.disabled = true;
    };

    if(this.count>0)
    document.getElementById('ContainerFile').style.dis play = 'block';

    // File element counter
    this.count++;
    // Most recent element
    this.current_element = element;

    var b = window.parent.document.getElementById('Tea');
    if(b != null) {
    document.getElementById('files').value = this.count;
    if(this.count > 1) {
    b.align = "right";
    }
    }

    } else {
    // This can only be applied to file input elements!
    alert( 'Error: not a file input element' );
    };
    };

    /**
    * Add a new row to the list of files
    */
    this.addListRow = function( element ){



    // Row div
    var new_row = document.createElement( 'div' );
    var filevalue= element.value;
    var filename="";
    // Delete button
    //var new_row_button = document.createElement( 'input' );
    //new_row_button.type = 'button';
    //new_row_button.value = 'Delete';

    // Delete Image
    var new_row_button = document.createElement( 'img' );
    new_row_button.src='Images/but_delete_on.gif';


    // References
    new_row.element = element;

    filename = filevalue;
    var l = filename.length;
    //Set the lenght of the filename to 50 with 10 blank spaces in the middle.

    if (l > 40){
    filename = filename.substring(0, 20) + '...' + filename.substring(l - 20);
    }

    var table = document.createElement('table');
    var row = table.insertRow(0);
    var img_cell = row.insertCell(0);
    var img = document.createElement('img');
    img.src = 'Images/but_delete_on.gif';
    img_cell.appendChild(img);


    img.onclick= function(){
    var el = this.parentNode.parentNode.parentNode.parentNode.p arentNode.element;

    el.parentNode.removeChild(el);
    this.parentNode.parentNode.parentNode.parentNode.p arentNode.parentNode.removeChild(this.parentNode.p arentNode.parentNode.parentNode.parentNode);
    el.multi_selector.count--;
    el.multi_selector.current_element.disabled = false;

    if(el.multi_selector.count == 1)
    document.getElementById('ContainerFile').style.dis play = 'none';

    var files = document.getElementById('files');
    files.value = files.value - 1;
    if(files.value - 1 == 0) {
    document.getElementById('Tea').align = 'left';
    }

    return false;
    };



    var cell = row.insertCell(1);
    cell.style.fontFamily = 'Verdana';
    cell.style.fontSize = '10px';
    cell.style.color = '#697780';
    cell.style.textDecoration = 'none';
    cell.style.fontWeight = 'bold';

    cell.innerHTML = "&nbsp;" + filename;
    new_row.appendChild(table);

    this.list_target.appendChild( new_row );

    };
    };
Working...
X