I would like to change the name of the image before uploading it to SharePoint document library. Below is the code i have written when an image is uploaded using HTML upload control. When the image is uploaded I am loading the propertied of the image into an object and with the help of the below commented code i tried to change the name of the image before uploading to SharePoint. looks like the name property of the image is set to read-only. Could someone please help me in figuring out a way to change the name of the image file before uploading to SharePoint document library.

Upload Code:

$scope.imageUpload = function () {


        document.getElementById("imgUploaded").src = $("#imgfilebrowse")[0].value;
        var CandidateDetails = $scope.profileById;
        if ($("#imgfilebrowse")[0].files[0] != null && $("#imgfilebrowse")[0].files[0] != '') {

            image = $("#imgfilebrowse")[0].files[0];

            //Image Object Name Change
            //var splitName = image.name.split('.');
            //var newName = splitName[0] + '_' + CandidateDetails.ID;
            //image.name = newName + '.' + splitName[1];
            //console.log('newName:' + newName);
            //console.log('Image Object Name:' + image.name);



$q.all([baseSvc.updateCandidateList('CandidateList', 'UpdateCandidate', CandidateDetails)]).then(function (data) {

                //execute the image upload functionality only if imageobject is not empty
                if (image != null && image != '') {
                    $q.all([baseSvc.documentUpload('Site Assets', 'ProfileImages', image, 'ImageUpload')]).then(function (data) {


Your Answer

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

Browse other questions tagged or ask your own question.