图片上传

来源:互联网 发布:ubuntu daemon 编辑:程序博客网 时间:2024/06/01 10:36

// 用input[file]上传图片

upLoadImg=(e)=>{        console.log(e.currentTarget.files[0]);        let file=e.currentTarget.files[0]        let url = null ;        // 获取图片上传的绝对路径        if (window.createObjectURL!=undefined) { // basic            url = window.createObjectURL(file) ;        } else if (window.URL!=undefined) { // mozilla(firefox)            url = window.URL.createObjectURL(file) ;        } else if (window.webkitURL!=undefined) { // webkit or chrome            url = window.webkitURL.createObjectURL(file) ;        }        let tempData=[...this.state.prizeuserdata];        tempData.push({            id: '',            url:url        });        this.setState({            prizeuserdata:[...tempData]        })    };
原创粉丝点击