2016-07-29 7 views
5

Issue: Error: FileConstructor is not a constructor (evaluating 'new File([blob], "filename.png")')AngularJS

मैं इस सवाल Alternative for File() constructor for safari देखा था, लेकिन को देख लायक किसी भी विकल्प वहाँ नहीं थे 'FileConstructor एक निर्माता नहीं है।'

क्या आईओएस पर आयनिक फ्रेमवर्क का उपयोग करके इस पर काम करने के लिए वैसे भी है?

जावास्क्रिप्ट

एक = Base64 छवि।

var blob = new Blob([a], {type: 'image/png'}); 

     console.log(blob); 
     $scope.Issue14 = blob; 

     var nfile = new File([blob], "filename.png"); 

     console.log(nfile); 
     $scope.Issue15 = nfile; 

     var _file = nfile; 

     console.log(_file); 
     $scope.Issue16 = _file; 

     $scope.Images.push({"img": _file}); 

उत्तर

4

मुझे फ़ाइल और सफारी के साथ एक ही समस्या का सामना करना पड़ रहा है। कुछ शोध करने के बाद मैं एक solution मेरे लिए काम करने लगता है कि पाया ... आशा है कि यह आपके लिए उपयोगी हो जाएगा:

के बजाय नई फ़ाइल का उपयोग कर, मैं संलग्न नाम और lastModifiedDate के खेतों द ब्लोब।

blob.name = "filename.png"; 
blob.lastModifiedDate = new Date(); 

यह एक फ़ाइल नहीं है, लेकिन आप इसे उपयोग कर सकते हैं जैसे कि यह था ...