Editor File upload

Editor File upload

farmerphfarmerph Posts: 10Questions: 2Answers: 0

I am trying to use Editor file upload so far it is working but it isn't. the file uploads to the correct location as soon as i select it.
My first Question
1. Is there a way to delay this? to use it with presubmit
2. I am also getting the error

'A server error occurred while uploading the file'

the weird part is the file is still saved in the correct location
I have read all of the discussions i could find on here retaining to this function. I still cant seem to figure out the JSON return format.
I am Using Editor.net 1.7.2

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    No - the file upload is async to the rest of the form at the moment. This is to allow the file to be linked to from a parent table with a simple left join (i.e. the file's id can be submitted along with the rest of the form).

    'A server error occurred while uploading the file'

    What is the server returning?

    Allan

  • farmerphfarmerph Posts: 10Questions: 2Answers: 0

    OK I fixed

    'A server error occurred while uploading the file'

    by removing
    return JSON(fileName)
    but now I get

    TypeMismatchError

    In datatables.js
    The response body

    {"draw":null,"data":[],"recordsTotal":null,"recordsFiltered":null,"error":null,"fieldErrors":[],"id":null,"meta":{},"options":{},"files":{},"upload":{"id":"SRD-1234.hex"},"debugSql":[],"cancelled":[]}

    and the modal shows the file name in the label below the upload control and the file is copied to its destination.

    My controller

    .Field(new Field("Hex_File")
        .Upload(new Upload((file, id) =>
            {
                var fileName = file.FileName.Substring(file.FileName.LastIndexOf("\\") + 1);
                var folderName = fileName.Split('.');
                var pathToCheck = req.PhysicalApplicationPath + @"\files\" + folderName[0];
                if (!Directory.Exists(pathToCheck))
                {
                    Directory.CreateDirectory(pathToCheck);
                }
                file.SaveAs(pathToCheck + @"\" + fileName);
                return (fileName);
            })
            .Validator(Validation.FileExtensions(new [] {"hex"}, "Select a \".hex\" file."))
        )
    )
    

    and the return in display
    display: function (Hex_File) { return Hex_File; },
    Hex_File returns the file name which is what i send back from the api.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Where is the TypeMismatchError happening please? If you are using the .min version at the moment, it would be useful to use the non-minified version so I can understand where in the code the error is happening.

    Allan

  • farmerphfarmerph Posts: 10Questions: 2Answers: 0

    I was not using the .min version for this reason I have been trying to troubleshoot for a couple of days.
    In this section

    /*
    * DataTables 1.10 API integration. Provides the ability to control basic Editor
    * aspects from the DataTables API. Full control does of course require use of
    * the Editor API though.
    */

    apiRegister( 'rows().delete()', function ( opts ) {
    // main
    var inst = __getInst( this );
    inst.remove( this[0], __setBasic( inst, opts, 'remove', this[0].length ) );
    return this;
    } );

    I do not have a remove button

  • farmerphfarmerph Posts: 10Questions: 2Answers: 0

    Oh and the line number for me is 95081

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Are you able to give me a link to the page (you can PM me the link by clicking my name above and then the "Send message" button, if you don't want to make the link public).

    Which line from that code block is breaking. It might be useful to know the values of the variables on that line as well.

    Allan

  • farmerphfarmerph Posts: 10Questions: 2Answers: 0
    edited March 2018

    This is an intranet website. I will not be able to make a public version until this weekend. I ran the site with debugging turned off in VS the TypeMisMatchError does not crash the site, and since the file copies I will push forward for now I will post an update when i have a live version for you to look at.

    Which line from that code block is breaking. It might be useful to know the values of the variables on that line as well.

    datatables.js
    Line: 95081

    apiRegister( 'cells().edit()', function ( opts  ) {
           // bubble only at the moment 
            __getInst( this ).bubble( this[0], opts );
        return this;
    } );
    

    --'opts' is undefined
    BREAKS at the comment LINE 95081
    Thats as much as i could get from IE Debug

  • farmerphfarmerph Posts: 10Questions: 2Answers: 0
    edited March 2018

    Side note none of this happens in chrome, unfortunately I can not use this browser.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thanks. Yes, I'm afraid I would need a link to the page in this case I think. If you do manage to publish it, it would be great if you could send the link over.

    Is it IE11 you are using?

    Allan

This discussion has been closed.