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

remove_File throwing excepption Options
sroughley
#1 Posted : Tuesday, February 16, 2010 7:09:42 AM
Rank: Newbie

Groups: Registered

Joined: 2/15/2010
Posts: 4

Hello,

When I call the function remove_File I get the exception: 'itemEl' is null or not an object. My ASPX page is as follows:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript">
    <!--
    function OnImageFileAdded(file) {
        var myreg = /^([jJ][pP][gG]|[jJ][pP][eE][gG]|[gG][iI][fF]|[pP][nN][gG])$/
        if (!myreg.test(file.extension)) {
            alert('Invalid file format. Only JPEG, GIF and PNG image files are allowed.');
            var imageFileSelectorId = '<%=ImagesFileSelector.ClientID %>';
            var fs = kw.get(imageFileSelectorId);
            fs.remove_File(file.id);
        }
    }
    function OnEpcFileAdded(file) {
        if (file.extension != "PDF") {
            alert('Invalid file format. Only PDF files are allowed.');
            var epcFileSelectorId = '<%=EpcFileSelector.ClientID %>';
            var fs = kw.get(epcFileSelectorId);
            fs.remove_File(file.id);
        }
        alert('EPC Added: ' + file.extension);
    }
    //-->
</script>
    <div class="fileinput imageupload">
        <h3>
            <asp:Label ID="ImageUploadLabel" runat="server" Text="Image Upload"/>
        </h3>
        <kw:FileSelector ID="ImagesFileSelector" runat="server" MaxFiles="9" OnClientFileAdded="OnImageFileAdded">
            <DownlevelTemplate>
                <label for="file1">1.</label><input id="file1" type="file" />&nbsp;<input id="description1" type="text" /><br />
            </DownlevelTemplate>
            <UplevelTemplate>
                <a href="#">Click here to add a picture</a>. You can add up to 9 pictures.               
            </UplevelTemplate>                       
        </kw:FileSelector>
        <kw:FileList id="ImagesFileList" FileSelectorId="ImagesFileSelector" runat="server">
            <FileTemplate>
                <kw:FileListFileName ID="FileListFileName1" runat="server" />
                <kw:FileListRemoveLink ID="FileListRemoveLink1" runat="server">[ remove ]</kw:FileListRemoveLink>
                <kw:FileListValidationMessage ID="FileListValidationMessage1" runat="server" ForeColor="Red" />
            </FileTemplate>
        </kw:FileList>
    </div>
    <div class="fileinput energycerts">
        <h3>
            <asp:Label ID="EnergyCertLabel" runat="server" Text="Energy Performance Certificate Upload"/>
        </h3>
        <kw:FileSelector ID="EpcFileSelector" runat="server" MaxFiles="1" OnClientFileAdded="OnEpcFileAdded">
            <DownlevelTemplate>
                <input id="file1" type="file" />&nbsp;<input id="description1" type="text" />
            </DownlevelTemplate>
            <UplevelTemplate>
                <a href="#">Click here to add an EPC</a>. You may add 1 certificate in PDF format.              
            </UplevelTemplate>                        
        </kw:FileSelector>
        <kw:FileList id="EnergyCertFileList" FileSelectorId="EpcFileSelector" runat="server">
            <FileTemplate>
                <kw:FileListFileName ID="FileListFileName1" runat="server" />
                <kw:FileListRemoveLink ID="FileListRemoveLink1" runat="server">[ remove ]</kw:FileListRemoveLink>
                <kw:FileListValidationMessage ID="FileListValidationMessage1" runat="server" ForeColor="Red" />
            </FileTemplate>
        </kw:FileList>
    </div>
    <kw:UploadConnector ID="UploadConnector1" runat="server" HideDuringUploadElements="BackImageButton,ContinueImageButton,ImagesFileList,EnergyCertFileList" ShowDuringUploadElements="CancelButton" />
    <div class="fileinputprogress">
        <kw:UploadProgressDisplay ID="UploadProgressDisplay1" runat="server">
             <ProgressTemplate>
                 <table width="100%">
                     <tr>
                         <td>
                             Uploading
                             <kw:UploadProgressElement ID="UploadProgressElement1" runat="server" Element="FileCountText" />,
                             <kw:UploadProgressElement ID="UploadProgressElement2" runat="server" Element="ContentLengthText">
                                 (calculating)
                             </kw:UploadProgressElement>.
                         </td>
                     </tr>
                     <tr>
                         <td>
                             <div style="border: 1px solid #b2b2b2; height: 20px; width: 400px;">
                                 <kw:UploadProgressBarElement ID="UploadProgressBarElement1" runat="server" style="background-color: #5683ba; width:0; height: 20px; color: #fff;" />
                                 <div style="text-align: center; position: absolute; top: 10px; width: 100%;">
                                     <kw:UploadProgressElement ID="UploadProgressElement8" runat="server" Element="PercentCompleteText">
                                         (calculating)
                                     </kw:UploadProgressElement>
                                 </div>
                             </div>
                         </td>
                     </tr>
                 </table>
             </ProgressTemplate>
        </kw:UploadProgressDisplay>
    </div>
    <div class="virtualnav">
        <asp:ImageButton ID="BackImageButton" ValidationGroup="" ImageUrl="~/lib/img/back.jpg" ToolTip="Back" runat="server" />
        <asp:ImageButton ID="ContinueImageButton" ValidationGroup="" ImageUrl="~/lib/img/next.jpg" ToolTip="Continue" runat="server" />
    </div>
</asp:Content> 

Axosoft
#2 Posted : Tuesday, February 16, 2010 4:39:34 PM
Rank: Administration


Groups: Administrators

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

In the latest builds, there's a better way to go about validating files before selection. We've added an OnFileAdding event that allows you to do a check on the file and return false if it shouldn't be added. I've attached the 5.4.3 RC build. Here's what to do:

 - Drop in this build (it includes the downlevel changes from the last build I gave you as well)
 - Change from using the OnClientFileAdded event to OnClientFileAdding event
 - Instead of calling remove_File, simply return false, something like: 

function OnImageFileAdding(file) {
        var myreg = /^([jJ][pP][gG]|[jJ][pP][eE][gG]|[gG][iI][fF]|[pP][nN][gG])$/
        if (!myreg.test(file.extension)) {
            alert('Invalid file format. Only JPEG, GIF and PNG image files are allowed.');
            return false;
        }
    }

File Attachment(s):
SlickUpload-5.4.3-RC.zip (55kb) downloaded 2 time(s).
sroughley
#3 Posted : Wednesday, February 17, 2010 7:35:26 AM
Rank: Newbie

Groups: Registered

Joined: 2/15/2010
Posts: 4

Thank you very much! This seems to do the trick, however I am now getting the error: Unexpected call to method or property access. I am using IE8 to develop/test. I have tried this in FF and do not get the error.

Axosoft
#4 Posted : Wednesday, February 17, 2010 10:51:39 AM
Rank: Administration


Groups: Administrators

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

Our cross browser test suite just picked up this issue as well. Drop in the attached build and that should solve it.

File Attachment(s):
SlickUpload-5.4.3-BlurFix.zip (55kb) downloaded 2 time(s).
sroughley
#5 Posted : Thursday, February 18, 2010 4:00:36 AM
Rank: Newbie

Groups: Registered

Joined: 2/15/2010
Posts: 4

Perfect! Thats fixed it. Thank you for the excellent support!

Stephen

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.