SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Remove File on Add Options
chrisajohn
#1 Posted : Tuesday, November 10, 2009 9:35:02 AM
Rank: Newbie

Groups: Registered

Joined: 11/10/2009
Posts: 8

I am using the file selector and filelist controls.  When a user adds a file, I am calling the "OnClientFileAdded" method.  In that method I am doing some checking to see what kind of file type it is.  What I would like to do, is remove the file from the list AND from the input (textbox with the browse button) if the file isn't of a certain extension (I can explain why if you wish, but its just some funky business requirements).

The code I am using is below.  Note the bolded text.  This is where I need to remove the file.  The file is removed from the list, however it still appears in the input textbox and if I click "Upload" it uploads the file I wanted to delete.

Thanks for your help.

function addFile(file) {

        if (file.extension != 'pdf') {
              //let the user know that non PDF docs cannot be merged.
              alert("You may only upload PDF documents to have them automatically merged.");
             
              //get the file selector
              var fileUpload = kw.get('<%= fsSelector1.ClientID %>');

              var files = fileUpload.get_Files();
             
              if (files.length == 1)
              {
                 //first file, don't show the file selector since the files is not .pdf format
                 document.getElementById('<%= dvFileSelector.ClientID %>').style.display = 'none';
                
                 //Disable the flatten option.
                 <%= ClientID %>_showHideFlatten(false);
              }
              else
              {
                 //since this isn't the first file and its a non-pdf, remove it from the list.
 
                fileUpload.remove_File(file.get_Id);
              }
            }
            else
            {
                var showFlattener = document.getElementById('<%= hfShowFlattener.ClientID %>');
                if (showFlattener.value == "1")
                {
                    //if its a pdf, make sure the flatten option is shown if applicable
                    <%= ClientID %>_showHideFlatten(true);
                }
            }
           
            //don't show the Form Editor or my library links since a file has already been chosen.
            document.getElementById('<%= dvEditorLink1.ClientID %>').style.display = 'none';
            document.getElementById('<%= dvMyLibrary.ClientID %>').style.display = 'none';
        }

 

 

Axosoft
#2 Posted : Thursday, November 12, 2009 11:27:50 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

We're still researching this issue. I should have a workaround or fix for you by the end of the week.

If you could, can you send your .aspx and codebehind to chrish at krystalware dot com so we can test with the specific code you're using and make sure everything works?

Axosoft
#3 Posted : Monday, November 16, 2009 7:45:48 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

This line:

fileUpload.remove_File(file.get_Id);

Should read:

fileUpload.remove_File(file.id);

Let me know if this solves the issue.

chrisajohn
#4 Posted : Monday, November 16, 2009 10:20:15 AM
Rank: Newbie

Groups: Registered

Joined: 11/10/2009
Posts: 8
This worked great! Thank you so much for your help!!
Users browsing this topic
Guest
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.