Options on sorted upload - Multi file select

Last post 03-25-2011, 2:00 PM by D2Wheelz. 1 replies.
Sort Posts: Previous Next
  •  03-24-2011, 12:40 PM 66838

    Options on sorted upload - Multi file select

    Requirement:  files selected to be uploaded in alphanumneric order after select
     
    most camers are going to take photos in some type of sequential order : DSC001.jpg, DSC002.jpg, ... DSC014.jpg    etc
     
    By Default if you select :  photo1,  then shift+photo14,   the upload order is :    DSC014, DSC001, DSC002  etc
    However If you select  : photo14, then shift+photo1,  the upload order stays sorted:     DSC001, DSC002... DSC014
     
    if I am able to get the QUEUE list & FileState ( no files to this point have been uploaded )
    function CuteWebUI_AjaxUploader_OnQueueUI(list){ 
      for (var i = 0; i < list.length; i++)
       { 
         photostr.push(list[i].FileName);  
       }
        photostr.sort();
       alert(photostr);
     }
    can the QUEUE TABLE be reordered ( sorted )?
     
    the long and cumbersome way seems to be to have to process (upload) the files in whatever default order they come in, ( now they could be correct if selected in reverse) , instead of having them be able to be renamed at this point,  ,  eval the JSON response reprocess the list, store it in an array , sort it , add a jquery call (or other) in the CuteWebUI_AjaxUploader_OnPostback() to rename the files
     
    or am i missing something some where?
  •  03-25-2011, 2:00 PM 66856 in reply to 66838

    Re: Options on sorted upload - Multi file select

    I figure let me post a followup to this incase it can help someone else.
     
    the second call is nessessary, so i figured if I needed to use one I might as well make it usefull.
     
     
    in the JS file where I call
     
    function CuteWebUI_AjaxUploader_OnPostback() {
     
    // grab some additional info
       var stock = document.getElementById("Stock");
       var stockv = stock.value;

       var vinnum = document.getElementById("VIN");
       var vinnumv = vinnum.value;

       var picnum = document.getElementById("picnum");
       var picnumv = picnum.value;
     
       var uploader = document.getElementById("myuploader");
       var guidlist = uploader.value;
    // since i dont know how many photos the user will select or how long the guidlist will be , append known values to the end
       
       var guidlist2 = guidlist + "/" + didv + "/" + stockv + "/" + picnumv + "/" + vinnumv;
     
    * now when this posts to the  ajax-multifiles-handler.php, and we exploded the post array
     
    $guidarray=explode("/",$_POST["guidlist2"]);
     
    i can count backwards to get my added vars
       $numofarray = count($guidarray)-2;
          $pnum = $guidarray[$numofarray]; // this is the picture number im looking for
     
    since i know how many vars i added i know how many to take off to get to the original guidarray sent
     
    foreach($guidarray as $fileguid)
    {
     if($count<$numofarray3){ // is part of FileGuide
     $mvcfile=$uploader->GetUploadedFile($fileguid);
     
     if(!$mvcfile)
      continue;
    .... // process file here
     
    since i am moving the file and renaming it
    I added a extra member  my new filename  to the JSON array being echoed
     
    the returning xh.responseText
    var list = eval(xh.responseText); //get JSON objects
      list.sort(SortByFileName); // create a function to sort on the original filename uploaded
     
    then in the loop
     for (var i = 0; i < list.length; i++)
       {
       photostr.push(list[i].FileNewName);  // create an array with only the NEWName
          }
      
       photostr = photostr.toString().replace (/\,/g, '|');    // replace commas with pipes
     
    now i have a string of new filenames in the proper sorted order  based on the original name,
    the original files are on the server with the new name.
     
    now i need to get them into the db, with the new name
    here is where i make the second call with a jquery to  a php page that creates a thumbnail of the image & inserts it values into the db
     
    and thats pretty much it. 
     
    if you would like to see it working
     
    goto  www.dealz2wheelz.com  and login to the members area with   demotest / demotest
     
    click on inventory and add a new vehicle,  you ll see the photo tab,  ( No porn !! )
     
     
     
     
View as RSS news feed in XML