Html文件上传预览的Javascript [英] Html file upload preview by 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屋!