upload of files with same filenames

Last post 09-24-2009, 11:29 AM by cutechat. 3 replies.
Sort Posts: Previous Next
  •  09-22-2009, 6:48 AM 55789

    upload of files with same filenames

    Is there an exempel how too prevent upload of files with same filenames.
    I use the multiupload (like gmail).
    I want AjaxUploader to cancel a fileupload if it allready is in the que or is allready uploaded. alt. rename the file with ex: filename_1.doc
  •  09-22-2009, 9:02 AM 55791 in reply to 55789

    Re: upload of files with same filenames

    bundy69,
     
    You can do the file name checking in Uploader_FileUploaded event.  Simply rename the uploaded files if the same file exists.
    1. void Uploader_FileUploaded(object sender, UploaderEventArgs args)   
    2.        {   
    3.            if (File.Exists(path))    
    4.                 args.CopyTo("c:\\temp\\new"+args.FileName)   
    5.            else               
    6.                 //Copies the uploaded file to a new location.   
    7.                 args.CopyTo("c:\\temp\\"+args.FileName);   
    8.        }  
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-23-2009, 12:44 PM 55820 in reply to 55791

    Re: upload of files with same filenames

    what if we want to prevent the user from queueing multiple duplicates files?
    this can be done by negating a selection if the user is selecting 1 file at a time to queue up but if a user is selecting multiple files at a time and one fo those files happens to be in the queue already the only way to prevent that duplicate from showing up in the queue is to cancel the entire selection since there is no way to cancel only the selection of the duplicate file or files if there is more than one. 

    one potential solution is to create a custom queue that does not display duplicate files and then prevents the saving of those files on the back end however the problem to that approach would be that the user then has to wait patiently while the duplicate files are uploaded regardless of whether or not they are actually saved after upload.

    How can we prevent  the upload of duplicate files in a clean and intuitive way that allows the selection of multiple files and only cancels the duplicate's selection and allows the rest to be queued up?
  •  09-24-2009, 11:29 AM 55854 in reply to 55789

    Re: upload of files with same filenames

    Hi,
     
    Currently we has a sample for that :
     
    You many need the last version for the Cancel funciton of the select event.
     
    <script type="text/javascript">
     //prevent duplicated items:
        function CuteWebUI_AjaxUploader_OnSelect(files)
        {
      var sames=[];
      var items=uploader.getitems();
      for(var i=0;i<files.length;i++)
      {
       var file=files[i];
       var exists=false;
       for(var j=0;j<items.length;j++)
       {
        var item=items[j];
        if(item.FileName==file.FileName)
        {
         exists=true;
        }
       }
       if(exists)
       {
        sames.push(file.FileName);
        file.Cancel();
       }
      }
      if(sames.length>0)
      {
       alert("These file(s) are already in the queue : \r\n\t"+sames.join('\r\n\t'));
      }
        }
    </script>
     
    Regards,
    Terry
     
View as RSS news feed in XML