Closed crapthings closed 5 years ago
Hey.. I use cordova cli directly. In that all I do is take the file URI that I get from the on success event then put it into an image which was specified as <img id="myImage">
within the html file. No other permissions are required to be explicitly specified in the config.xml.
var image = document.getElementById('myImage');
image.src = imageURI;
i've tried cordova cli, but still same result, something like no permission to read file
10.3 ?
let me try again
i've made a video to explain how to display image with wkwebview this can apply to this cordova plugin as well
https://github.com/crapthings/cordova-upload-file-example
https://www.youtube.com/watch?v=HUestthvr50
to display an image you have to use something like window.Ionic.WebView.convertFileSrc(cordova ionic web view)
const image = document.getElementById('preview')
image.src = window.Ionic.WebView.convertFileSrc(fileUrl)
plus if you want to upload file from html input rather then FileURL this is the minimal example to work with.
<form>
<input type='file' name='file' />
</form>
document.querySelector('input').onchange = function(evt) {
const data = new FormData(evt.target.form)
const xhr = new XMLHttpRequest()
xhr.open('POST', 'http://localhost:3000', true)
xhr.send(data)
}
var express = require('express')
var multer = require('multer')
var upload = multer({ dest: 'uploads/' })
var app = express()
app.post('/', upload.single('file'), function (req, res, next) {
console.log(req.file)
res.json(req.file)
})
app.listen(3000)
what permission should i enable on ios and android, it looks both os doesn't allowed access file:// on default
An example file URI obtained from success call back of scanDoc function looks like this file:///var/mobile/Containers/Data/Application/8376778A-983B-4FBA-B21C-A4CFDD047AAA/Documents/image.png
i already add this line into head
and with meteor there's a mobile-config that can mapping cordova config.xml like this
into