有什么办法没有它上传到服务器,以显示在客户端浏览器的形象? [英] Is there any way to display image in client browser without uploading it to server?
问题描述
我写一个简单的书在ASP.NET MVC创建页面。用户可以通过填写标题,年份等。并选择封面图片创建的书。当用户preSS创建按钮形式向外发送的图像和数据,以所谓的创建,然后我将图片保存到磁盘和数据的数据库控制器动作。
I am writing a simple "Book" create page in ASP.NET MVC. User can create book by filling title,year etc.. and selecting a cover image. When user press "Create" button Form sends image and data to Controller action called "Create" then I save image to disk and data to database.
但我要当文件dialog.To用户选择图像这样做是为了展示形象,据我所知,我必须上传图片到服务器,然后在客户端显示browser.But如果用户上传影像后取消了创建操作,图像将保留在服务器的disk.So我该如何处理这些临时的图像或有什么办法没有上传到服务器,以显示在客户端浏览器的形象?
But I want to display image when user select image by file dialog.To do this As far as I know I must upload image to server then display in client browser.But if a user cancels the "Create" operation after uploading image, the image will remain in the server's disk.So How can I deal with these temp images or Is there any way to display image in client browser without upload to server?
推荐答案
由于安全原因,您将不能没有他们上传到服务器,以显示图像的用户。从文件系统中显示图像被认为是一个安全隐患。
Due to security reasons, you will not be able to display the images to the users without uploading them to the server. Displaying images from file system is considered a security risk.
编辑:删除未使用的图像,你可以创建一个线程来运行清理例程将从定期上传目录中删除它们。
To remove the unused images, you can create a thread to run a cleanup routine to which will delete them from the upload directory regularly.
这篇关于有什么办法没有它上传到服务器,以显示在客户端浏览器的形象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!