我正在从事一个Reactjs项目,在那里我可以上传和下载文件。
但是当我上传一个文件时,Axios的请求在文件完全上传到我的数据库之前就已经完成了。我使用onUploadProgress从Axios,它直接显示100%后,我点击上传按钮,但文件还没有上传。
甚至看起来,上传的文件在背面,只有在一次进度条达到100%。我不知道如何正确同步进度条与文件上传。
我的代码
前沿
onUpload() {
const data = new FormData();
for (var i = 0; i < this.state.selectedFile.length; i++) {
我正在尝试上传多个文件,现在我只能上传一个文件,如何从不同的输入文件上传3个文件 import React from "react";
import axios, { post } from "axios";
;
import moment from "moment";
import "./calendar.css";
export default class Dashboard extends React.Component {
constructor(props) {
super(props);
我在Vue中使用了以下代码。在这里,我使用多个axios请求同时上传多个文件。在这段代码中,一切都运行正常。但我想要一种方法来查看一个文件上传了多少%。看,有一个有进度属性的文件对象数组this.upload。所以我想为特定的对象更新这个属性。这样我就可以向用户显示文件上传进度 for(var file of event.target.files){
if(!this.isValidFormat(file)) continue;
var thumb = await this.getThumb(file);
我只是想显示一个上传的图像。我不想保存到服务器上,只想显示上传的图片。
我正在使用
<p><img src={this.state.selectedFile}/></p>
以显示图像。
这是我的App.js文件:
import React,{Component} from 'react';
class App extends Component {
state = {
// Initially, no file is selected
selectedFile: null
};
// On file
Im running into a problem related with file uploading. I正在制作一个基于react库的Dropzone组件.我需要上传文件,并显示上传进度的每一个。此外,我想保持我上传的文件(结果)在区域和删除仅通过用户点击。
这是我的回复声明。
return (
<Container {...getRootProps({ isDragActive, isDragAccept, isDragReject })}>
<input {...getInputProps()} />
{filesToRend