在本地存储来自HTML输入文件表单的图像 [英] Storing the image from an HTML input file form locally

查看:94
本文介绍了在本地存储来自HTML输入文件表单的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以存储图像

I was wondering if it is possible to store the image from

<input type="file" id="image">

本地。我是否必须存储图像,还是只需存储图像位置?

locally. Would I have to store the image, or could I simply store the image location?

对于上下文,它来自一个从输入表单中获取名称,地址等的表单,创建对象,将其存储在数组中并显示数组。

For context, it's from a form that takes name, address etc from input forms, creates an object, stores it in an array and displays the array.

推荐答案

否。由于在本地操作系统上存储文件或访问文件会违反浏览器的权限。因此,除非已将内容上载到服务器,否则您的脚本无法访问内容。此外,不同的浏览器处理以不同方式选择的文件的路径。所以你在那里遇到了很多问题。

No. Since storing a file or accessing a file on the local OS would violate the permissions of the browser. So your scripts cannot access the content unless it has been uploaded to the server. Also different browsers handle the path of the file that has been selected in different ways. So you encounter a number of problems there.

这就是说,有一些方法可以解决这个问题我不会讨论。简单地说,应该以某种方式将图像上传到服务器,然后您的脚本可以从上传到的路径引用路径或图像本身。

That said, there are some ways to get around this that I will not discuss. Simply put, the image should be uploaded to the server in some fashion and then your scripts can reference the path or the image itself from the path that it was uploaded to.

这篇关于在本地存储来自HTML输入文件表单的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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