如何使用文件上传控件选择图像后立即预览上传的图像 [英] How to preview uploaded image as soon as image is selected using file upload control

查看:81
本文介绍了如何使用文件上传控件选择图像后立即预览上传的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想显示所选图像的预览,因为它是使用文件上传控件选择的.
我尝试了ajaxfileuploader和Ajax调用,但是由于我的文件上传控件位于.ascx文件(用户控件)中,因此它对我不起作用.
我无法直接在客户端获取所选文件的完整路径,也不想在选择文件时刷新页面(获取路径).

请帮我.我严重陷入这个问题.



在此先谢谢您..

Hello,

I want to show preview of selected image as it is selected using file upload control.
I tried ajaxfileuploader and Ajax call but as my file upload control is in .ascx file(user control) it is not working for me.
I am not able to get whole path of selected file at client side directly and I don''t want to refresh page on selection of file (to get path).

Please help me. I am badly stucked in this problem.



Thanks in Advance..

推荐答案

您在ascx中的事实是无关紧要的.您需要发布无效"含义的详细信息.尽管我可以看到AJAX控件将如何做到这一点,但没有理由立即上传控件.出于安全原因,对文件上载控件的详细信息的访问受到限制,但是,如果您可以读取其中的值,则可以编写自己的JavaScript代码以通过从客户端读取图像来显示图像(这是唯一的位置)当时存在).

我看到您添加了一些细节.

我怀疑是否有可能在客户端获得完整的路径.对于某些浏览器,您甚至无法在服务器上获得完整的客户端路径.您是否在多个浏览器上进行测试?我怀疑您想做什么,需要页面中托管的控件.

我在Google上搜索并确认,您不能这样做.
The fact you''re in an ascx is irrelevant. You''d need to post details of what ''not working'' means. There''s no reason for a control to upload immediately, although I can see how an AJAX one, would do that. Access to the details of the file upload control is limited, for security reasons, but if you can read the value in there, you can write your own javascript code to show the image by reading it from the client ( that being the only place it exists at that time ).

I see you added some detail.

I doubt it''s possible to get the full path on the client side. And with some browsers, you can''t even get the full client side path on the server. Are you testing on more than one browser ? I suspect to do what you want, needs a control hosted in the page.

I googled and confirmed, you can''t do it.


这篇关于如何使用文件上传控件选择图像后立即预览上传的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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