No response from snAttachmentHandler.create from table
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â03-04-2024 08:59 AM
Hi All,
I am working on the attach file on the db_image table, after uploading i am not getting any response from snAttachmentHandler.create
Here is my code,
HTML
<input ng-show="false" type="file" accept="image/jpeg,image/png,image/bmp,image/x-windows-bmp,image/gif,image/x-icon,image/svg+xml" ng-file-select="attachFiles({files: $files})" />
<button ng-click="uploadNewProfilePicture($event)"
type="button"
class="btn btn-default send-message">${Upload Picture}</button>
Client Script:
function($scope, $element, $window, $location, $rootScope, $timeout, snAttachmentHandler, $http, spUtil, userPreferences, $filter, i18n, $uibModal, spAriaUtil, nowAttachmentHandler) {
/* widget controller */
var c = this;
$scope.uploadNewProfilePicture = function($event) {
$event.stopPropagation();
var $el = $element.find('input[type=file]');
$el.click();
}
$scope.attachFiles = function(files) {
if (!files.files.length)
return;
var file = files.files[0];
var validImage = false;
switch(file.type) {
case 'image/jpeg':
case 'image/png':
case 'image/bmp':
case 'image/x-windows-bmp':
case 'image/gif':
case 'image/x-icon':
case 'image/svg+xml':
validImage = true;
break;
default:
break;
}
if(!validImage) {
alert(file.name + " " + i18n.getMessage("isn't a recognized image file format"));
return;
}
snAttachmentHandler.create("db_image", "").uploadAttachment(file, {
sysparm_fieldname: "name"
}).then(function(response) {
console.log(response);
});
}
0 REPLIES 0