Access Denied Error For Opening File With Anchor Tag
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up HTML tag download file error handling up vote 4 down vote favorite 1 In my app I have tag with link to api for file download (pdf). The problem is that it is not 100% stable and I have to handle then service is not available or file is not available and server responds with error. By the way I am using AngularJS in this app. If there is any solution using it it would help a lot html angularjs share|improve this question asked Mar 3 '15 at 7:59 Ricardas 15612 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted In case somebody else will face similar problem. Here is the solution I have implemented after some research. Remove link from tag and add click event: now you need to download blob (here you can control if you can access it file) and let make DOM object add all needed attributes end trigger it. $scope.downloadFile = function () { $http.get('api/link', { responseType: 'arraybuffer' }) .success(function (data) { var file = new Blob([data], { type: "application/pdf" }); var url = $window.URL || $window.webkitURL; var fileURL = url.createObjectURL(file); var a = document.createElement("a"); a.href = fileURL; a.download = "nameOfFile; a.target = "_self"; a.click(); url.revokeObjectURL(fileURL); }).error(function (data) { console.error(data); }) }; UPDATE: This was working only for Chrome. Other browsers had different appro
One games Xbox 360 games PC games Windows games Windows phone games Entertainment All Entertainment Movies & TV Music Business & Education Business Students & educators Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security http://stackoverflow.com/questions/28826747/html-a-tag-download-file-error-handling Internet Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Band Microsoft https://support.microsoft.com/en-us/kb/908356 Lumia All Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft
Support Search GitHub This repository Watch 288 Star 6,695 Fork 1,385 danialfarid/ng-file-upload Code Issues 66 Pull requests 6 Projects 0 Wiki Pulse Graphs New issue file upload in IE8 and IE9 with angular-flie-upload using triger #439 https://github.com/danialfarid/ng-file-upload/issues/439 Closed msnpr567 opened this Issue Dec 4, 2014 · 19 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 4 participants msnpr567 commented Dec 4, 2014 I got successfull file upload in IE8 and IE9 with angular-flie-upload. but iam using triger to click on browse input with the help of anchor tag. At that time im getting "Access denied " error in console. Im searching for solution through a access denied day but i didnt get. can u help me once. Owner danialfarid commented Dec 4, 2014 Cause of security issues there is no way to programmatically click on a Flash object button, so you gotta have transparent upload button on top of element that the user clicks on. That's what the plugin does if you have a div element with ng-file-select. msnpr567 commented Dec 6, 2014 Ok.. thanku . Just today i observed an access denied error issue that is , my file is uploading successfully and shows response in network .but $upload.upload() method is entering into Error block instead of success , this problem caused only in IE9 , remaining all are good. can u show me fix. my code is below $upload.upload({ url: 'url', method: 'POST', file: $scope.imageFile, data:{ headers: {'Content-Type': undefined } }, transformRequest: angular.identity }).then(function(data, status, headers, config) { console.log('image response geting block') $scope.isImageLoading = false; if(data.status='success'){ $scope.imgUrl = data.imgUrl; } }); Owner danialfarid commented Dec 6, 2014 Does it actually upload it to your server? What response code your server returns? And make sure your server response has some content, empty content won't trigger the success response. msnpr567 commented Dec 7, 2014 Ya im sure about upload... actually im uploading image , It will return a url in response. After refreshing page i was able to view uploded image. but Im not idetifying my response in .then block . do u have any personal number to talk. its a critical issue for me, i was unable to solve this. msnpr567 commented Dec 8, 2014 hi. have u understand my issue.... My file is uploading succesfully. but in my $upload.upload() response enters into error block not success. Issue raised in only IE9 .. can u show me solution pls Owner danialfarid commented D