使用文件对话框获取客户端文件的完整文件路径 [英] Getting full file path of a clients file using a file dialog box

查看:113
本文介绍了使用文件对话框获取客户端文件的完整文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试允许用户将图片上传到服务器.

I am trying to allow users to upload pictures to the server.

我正在尝试创建与具有附加"文件或上传图片"功能的任何网站类似的系统.我所需要做的就是获取通过文件对话框选择的文件的完整路径.

I am trying to create a similar system to any website that has an 'attach' file or 'upload image' feature. All I need is to get the full path of the file select by the file dialog.

我尝试将其用于文件对话框,但没有成功:

I tried using this for the file dialog with no success:

<input type="file">

由于安全原因,此方法不提供完整的文件路径.我的问题是如何创建类似于tinypic,photobucket等网站的输入对话框,以帮助用户将给定图像的完整文件路径输入到输入字段中?

This method does not provide the full file path, due to security reasons. My question is how can I create a similar input dialog to websites like tinypic, photobucket, etc.. that can help users input the full file path of a given image, into an input field?

我知道出于安全原因,无法使用上述方法完成此操作,但是,我之前在各种网站上都看到过此操作,没有任何问题,我想知道我该怎么做才能实现类似的文件对话框,从而有助于填写输入字段的文本,即完整的文件路径?

I am aware that this cannot be done using the method above for security reasons, however, I have seen this done before on various websites without any problems, I was wondering what I had to do to implement a similar file dialog that helps fill in the text, which is a full file path, of an input field?

推荐答案

无法使用浏览器和JavaScript在本地计算机上获取文件的完整路径.

但是,正如您希望将文件上传到服务器一样,我看到的最简单的可能性是将HTML表单与input type file一起使用.提交表单后,您将在http服务器上收到文件.

However, as you would like to upload the file to the server, the easy possibility I see is to use html form with input type file. You will receive the file on your http server when the form is submitted.

这是一个非常好的网址 http://www.cs.tut .fi/〜jkorpela/forms/file.html 很好地解释了整个过程.

Here is a very good url http://www.cs.tut.fi/~jkorpela/forms/file.html that explains the whole process nicely.

这篇关于使用文件对话框获取客户端文件的完整文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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