用ReactJS上传图片 [英] Image upload with ReactJS

查看:138
本文介绍了用ReactJS上传图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建此ReactJS应用程序,我想在其中单击一个按钮上传图像,然后将其转到下一个视图,即裁剪窗口,然后在裁剪后将其上传到服务器.

I’m building this ReactJS application which where I want to upload an image using a click of a button and take it to the next view which is the cropping window and then after cropping it, then I can upload it to the server.

我现在遇到的问题是如何在不将图像上载到服务器的情况下将图像从1个视图拍摄到另一个视图?

The issue which I’m having right now is how to take an image from 1 view to another view without uploading it to the server?

我尝试采用图像路径,但是不幸的是,当UI刷新时,该路径将被刷新.

I tried taking the image path, but unfortunately when the UI refreshes, the path will get flushed.

那么,在这种情况下我可以使用哪些选项.

So, what are the options which I can use in this situation.

谢谢!

推荐答案

昨天我研究了类似的案例.我正在使用react-dropzone返回上载的文件,文件对象中的字段之一是预览",它包含当前上传的文件的uri(可能已以某种方式缓存了,但我尚未对其进行调查). 在另一种观点中,您只是在做

Yesterday I worked on similar case. I'm using react-dropzone which returns uploaded files, one of the field in file object is 'preview', it contains uri of currently uploaded file (It's probably cached somehow, but I didn't investigate it yet). In another view you just doing

这篇关于用ReactJS上传图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆