0

I want to create an aspx file where I will have a tab to upload a file in SharePoint Online library. On upload, I want to check whether the file title is having the correct format or not. If file is not having the right format, I have to request user to check for the format. So, can some one help me with this?

0

Sample regex for file type validation, hope it would help you.

// Get test values from the file input and text input page controls.
        var fileInput = jQuery('#getFile');
        var newName = jQuery('#displayName').val();

        var parts = fileInput[0].value.split('\\');
        var fileName = parts[parts.length - 1];
        var fileRegex = new RegExp('\.[^.\\/:*?"<>|\r\n]+$');
        var fileType = fileName.match(fileRegex)[0];
        //todo

You could use official demo to upload file(above test demo is based on official demo also).

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/upload-a-file-by-using-the-rest-api-and-jquery#code-example-2-upload-a-file-in-the-same-domain-by-using-the-rest-api-and-jquery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.