Html文件上传预览的Javascript [英] Html file upload preview by Javascript

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

问题描述

我想在帖子中显示PREVIEW类型的内容,所以通过JS详细介绍了



,但是当涉及到<时;输入类型=文件,它没有给出文件的完整路径

例如:
如果我做了

  $(#image)。val(); 

只给出Sunset.jpg而不是C:\ Documents and Settings \ All Users。 ... \Sunset.jpg

任何想法如何获得详细值?

解决方案

尽管正如其他人已经指出的那样,您无法在JavaScript中学习文件的完整路径,也许完全不同



只要访问者选择了它,您就可以自动上传照片(您在Gmail中看到的行为,以及其他应用程序),所以即使访问者继续与您的页面进行交互,它仍驻留在您的服务器上。在这一点上,显示预览非常简单,只需从您自己的(现在是服务器端)映像副本中为您自己提供即可。


I want to show a PREVIEW kind of thing for an post , so took details by JS

but problem comes when it comes to <input type="file" , it's not giving full path to the file

Ex: if I do

$("#image").val();

it only give "Sunset.jpg" not C:\Documents and Settings\All Users....\Sunset.jpg

any idea how to get that detail value?

解决方案

Although, as others have already pointed out, you cannot learn the full path to the file in JavaScript, perhaps a completely different approach to the problem might still work for you.

You could upload the photo automatically as soon as the visitor has picked it (the behavior you see in GMail, among other applications), so it's residing on your server even as the visitor continues interacting with your page. At that point, showing a preview is as simple as serving one yourself from your own (now server-side) copy of the image.

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

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