我试图从我的离子2应用程序访问输入文件的值,但我仍然面临类型'EventTarget'上不存在属性文件的问题.因为它适用于js而不是打字稿.代码如下:
document.getElementById("customimage").onchange= function(e?) {
var files: any = e.target.files[0];
EXIF.getData(e.target.files[0], function() {
alert(EXIF.getTag(this,"GPSLatitude"));
});
}
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题,因为它没有构建我的离子2应用程序.
我正在使用https://www.npmjs.com/package/react-exif-orientation-img包,并且图像无法在react.js中正确显示
检查了chrome和mozilla,但似乎不起作用。
image-orientation css属性仅在Chrome中有效,因此请使用库。
import React, { Component } from 'react';
import ExifOrientationImg from 'react-exif-orientation-img';
import { Grid, Col, Row } from 'react-bootstrap';
class App extends Component {
render() {
const orientations = [1, 2, 3, 4, 5, 6, 7, 8];
const images = [2];
return (
<div>
<Grid fluid>
<Row className="show-grid">
{
images.map(index =>
<Col xs={3}>
<ExifOrientationImg
key={`demo_${index}`} className={'img-responsive'}
src={`https://testexif.blob.core.windows.net/exifimages/${index}.jpg`}
/>
</Col>
)}
</Row>
<Row className="show-grid">
{
orientations.map(index =>
<Col xs={3}>
<ExifOrientationImg
key={`l_${index}`} className={'img-responsive'}
src={`https://testexif.blob.core.windows.net/exifimages/Landscape_${index}.jpg`}
/>
</Col> …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,用户可以上传 PDF,其他用户稍后可以查看。对于我的用例,我需要确保 PDF 没有被锁定或加密,并且任何其他用户都可以查看。
为此,我要求用户上传未锁定的 PDF,并希望在尝试上传到 S3 之前,如果 PDF 已锁定,则抛出错误。
我还没有就在浏览器中执行此操作的最佳方法达成共识?我是否尝试读取缓冲区并在无法读取时抛出错误?或者是否有另一种高性能且有效的方法来检测这一点?
在javascript中,使用exif-js提取图像文件的元数据时,我将日期时间格式设置为2017:03:09 14:49:21。
DateTimeOriginal属性中的值格式为YYYY:MMY:DD HH:MM:SS。当我使用var d = new Date(2017:03:09 14:49:21)时,它返回NaN。是YYYY,MM和DD之间的冒号引起了问题。
如何解决这个问题呢?
提前致谢。
我正在尝试获取在 React 中使用输入标签上传的图像的 exif 元数据,并将以下函数附加到输入标签的属性“onChange”:
onChange(e) {
const { input: { onChange } } = this.props;
let img_arr = [];
for (let i = 0; i < e.target.files.length; i++) {
const file = e.target.files[i];
console.log('exif data');
console.log(EXIF.getData(file, () => {
var orientation = EXIF.getTag(this, "Orientation");
console.log('orientation');
console.log(orientation);
}));
img_arr.push({file: file, url: URL.createObjectURL(file)});
}
//console.log("printing img arr");
//console.log(img_arr);
onChange(img_arr);
}
Run Code Online (Sandbox Code Playgroud)
但是,我得到 EXIF 未定义。在exif-js页面,建议使用window.onload。https://github.com/exif-js/exif-js。如何在 React 组件中使用 window.onload ?
- 编辑 -
我将代码更改为这样,但方向仍然未定义:
onChange(e) {
const { input: { onChange } …Run Code Online (Sandbox Code Playgroud) exif-js ×5
javascript ×4
reactjs ×3
exif ×2
angular ×1
date ×1
datetime ×1
ionic2 ×1
pdf ×1
typescript ×1