We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

two questions about ejUploadbox

Hello,

I would like to know if there are samples or information about how to do these two things with ejUploadbox.

  1. After the upload(s) are complete, change the text of the cancel button to "OK" or "Close". Since the upload is now complete, the button text should logically be something other than "Cancel".

  2. If there is an error, is it possible to present some detail about the error to the user?  I see that the error event returns the parameters: model, type, and files.  In the event of an error, e.type appears to just be the text "error".  Is there documentation about how to use the model and files parameters?

thanks,

Randy


9 Replies

RC Randy Craven November 6, 2014 02:52 AM UTC

I figured out how to do #1:

    $(function () {
        $("#UploadDefault").ejUploadbox({
            complete: "fileuploadcomplete",
            saveUrl: "../../saveFiles.ashx",
            removeUrl: "../../removeFiles.ashx"
        });
    });
    function fileuploadcomplete(e, ui) {
        $("#UploadDefault").ejUploadbox({ buttonText: { cancel: "OK" } });
    }




RC Randy Craven November 6, 2014 03:00 AM UTC

Here are some other things about ejUploadBox that would be good to know:

  • how to set the size of the "Browse" button?
  • how to set the position of the ejUploadBox within the browser window?
  • how to alert the user if they have selected a file with extension not in the "extensionsAllowed" list?

Thanks very much for any information about these items.

Randy



RC Randy Craven November 6, 2014 03:59 AM UTC

I would like to ask one more question about ejUploadBox:

How to pass additional parameters to an MVC controller when the file upload is complete?  For example, if a customer can upload a file, it might be desirable to pass the customer id to the controller action so that files from different customers could be segregated on the server.

Thanks!

Randy


RC Randy Craven November 6, 2014 05:27 AM UTC

answer to: How to pass additional parameters to an MVC controller when the file upload is complete?


    function fileuploadcomplete(args) {
        $.post('@Url.Action("Action", "Controller")', { fileName: args.files.name, customerID: '@Model.CustomerID' });
    }






SN Sasikala Nagarajan Syncfusion Team November 7, 2014 03:41 AM UTC

Hi Randy Craven,

Thanks for using Syncfusion components,

Query: Is it possible to present some detail about the error to the user?

In our ejUploadbox, we have provided the action argument in the error event. Action argument provide the cause of the error. Different values of the action argument in error event.

action – ExtensionAllow : If the error event triggered due to the user select the file other than the files that are listed in extensionAllow.

action – ExtensionDeny :  If the error event triggered due to the user select the files that are listed in ExtensionDeny.

action – Error : If the error event triggered due to the URL not found.

We didn’t provide the full details of error in the error event. We have consider this as an issue (“Need to give full information about error”). We have logged an issue report for this. Fix for this issue will be available in our next service pack release which is expected to be rolled out at the end of the next month. We will notify you once our service pack release is rolled out. If you want the fix sooner please let us know, so that we can provide you patch for this fix on or before (27th November).

Query: Is there documentation about how to use the model and files parameters

There is no separate documentation for how to use model, files arguments in the error event. Please find the below information to know more about files, model arguments.

In files argument we can get the following information.

1.      Extension of file (extension)

2.      Name of the file(name)

3.      File properties(rawfile)

a.       lastModified

b.      lastModifiedDate

c.       name

d.      size

e.       type

4.      Size

Please find the below code snippet, to know how to use files arguments

[javascript]

function errorhandling(args) {

           alert(args.files[0].name);

           alert(args.files[0].rawFile.lastModifiedDate);

 }

In model argument we can get our ejuploadbox API values like extensionsAllow, multiplefileSlect, cssClass etc.

Please find the below code snippet to access the model argument.

[javascript]

function errorhandling(args) {

           alert(args.model.multipleFilesSelection);

           alert(args.model.buttonText);

 }

 

Queries:  how to set the size of the "Browse" button? How to set the position of the ejUploadBox within the browser window?

Sorry for the inconvenience caused. We didn’t provide any specific options for changing size and position of the upload box browse button. We have consider this as issue (“There is no option to change the size and position of the upload box”). We have logged an issue report for this. Fix for this issue will be available in our next service pack release which is expected to be rolled out at the end of the next month. We will notify you once our service pack release is rolled out. If you want the fix sooner please let us know, so that we can provide you patch for this fix on or before (27th November).

Query: how to alert the user if they have selected a file with extension not in the "extensionsAllowed" list?

We have analyzed your requirement. We can achieve your requirement using error event .We have prepared the sample based on your requirement and you can download this sample under the following location:

Sample: Uploadbox with Size

Regards,

Sasikala Nagarjan



RC Randy Craven November 9, 2014 09:47 PM UTC

Hello Sasikala,

Thank you for your reply and this information.  It is very useful.  It's not necessary to send a patch, just please let me know when the service release is available.

I would like to ask one more question:  Is it possible to get the name of the upload box div itself from the arguments passed to the complete event?  Something like the code below:

<div id="UploadDefault"></div>
<script>
    $(function(){
            $("#UploadDefault").ejUploadbox({
                complete: "onComplete"
            });
    });
    function onComplete(args){
       
        // retrieve the div name 'UploadDefault' from arguments

    }
</script>


Thank you again,
Randy



SN Sasikala Nagarajan Syncfusion Team November 10, 2014 01:11 PM UTC

Hi Randy Craven,

Thanks for the update.

We have analyzed your reported scenario. There is no arguments are passed to get the “id” of the upload box in the “complete” event. To get the id of the upload box’s div, please find the below code snippet.

function onComplete(args)

      {

       alert(“ID of the uploadbox”+ this.element[0].id);

      }

In above code snippet this.element[0].id” returns the id of the uploadbox’s div.

Also, our next service pack release is expected to be rolled out at the end of the November month

Please let us know if you need any further assistance.

Regards,

Sasikala Nagarajan



JK Jitender Kumar April 29, 2016 07:21 AM UTC

Hi Sasikala Nagarajan,

I have a problem with both jquery syncfusion UploadBox $("#divUploadBox").ejUploadBox({...}) and MVC Upload box @Html.EJ().UploadBox("MyUploadBoxId"). These controls are working fine on local system while running from Visulal Studio. But these are not working on IIS Server as the Action and Controller path given in the  saveURL (saveURL: "/ControllerName/SaveDefault") is not detecting on IIS .
Please suggest what should be done to resolve this on IIS.

Thanks & Regards,
Jitender 





MS Muralishankar Sundaram Syncfusion Team May 2, 2016 09:45 AM UTC

Hi Jitender,    
  
Thanks for your update,    
  
In order to handle the reported issue -“ these are not working on IIS Server as the Action and Controller path given in the  saveURL (saveURL: "/ControllerName/SaveDefault") is not detecting on IIS.” we suggest you to use @Url.Action URL helper, which will form the action URL based on the application configuration. Please find the sample snippet below:   
 
[View- CSHTML] 
 
<code> 
 
@Html.EJ().Uploadbox("UploadDefault").SaveUrl(@Url.Action("SaveActionName","ControllerName")).RemoveUrl(@Url.Action("RemoveActionName ","ControllerName")) 
 
</code> 

We have prepared the simple uploadbox sample with the use case scenario and refer the below link:   http://www.syncfusion.com/downloads/support/forum/117547/ze/WebApp-1253510022  

Please let us know if you have any other concerns. 

Regards, 
Muralishankar 


Loader.
Live Chat Icon For mobile
Up arrow icon