将文件下载到客户端系统中的特定位置 [英] download a file to particular location in client system

查看:136
本文介绍了将文件下载到客户端系统中的特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我编写的要下载文件的代码,
现在我需要将文件下载到客户端系统中的特定位置。我将通过用户输入获得路径。
我知道弄乱客户端系统不是很好,但是我必须这样做

Below is the code i've written i've to download a file, Now I need to download the file to particular location in client system.I'll get the path through input from the user. I know it's not good to mess client system but I had to do that

        //setting the content type of response
        response.setContentType("application/"+strFileType);

        response.setHeader("content-disposition","attachment; filename="+strFileName+"."+strFileType);

        //creating a file input stream object
         InputStream input = blob.getBinaryStream();

         //declaring a variable
         int i;
         while((i=input.read())!=-1)
         {
             //writing output
             printWriter.write(i);
         }

         //closing the streams
         input.close();
         printWriter.close();


推荐答案


我知道不是搞砸客户端系统很好,但是我必须这样做....

I know it's not good to mess client system but I had to do that ....

好消息(从用户的角度来看)是你做不到的。即使您必须。专门构建了Web浏览器来阻止您(服务器端)执行此类操作。

Well the good news (from the user's perspective!) is that you can't do it. Even if you "have to". A web browser is built specifically to stop you (the server side) from doing that kind of thing.

唯一的解决方法是在Trusted浏览器中实现功能。

The only away around this is to implement the functionality in a TRUSTED browser plugin or applet or something that the user has to specifically install on his / her machine.


...在哪里使用从用户那里获取的路径,我正在像ftp一样编程,但是服务器端是数据库

... where to use the path taken from the user and i'm programming this just like ftp but server side is a database

问题在于,浏览器无法判断您是否出于正当目的……或试图破坏系统/用户文件,植入恶意软件或 的任何其他事物>对用户有害。

The problem is that the browser has NO WAY to judge whether you are doing this for legitimate purposes ... or as an attempt to clobber system / user files, plant malware or any number of other things that may be harmful to the user.

这不会冒险让您这么做,这是一件好事。

It ain't going to take the risk of letting you do it, and that is a GOOD THING.

这篇关于将文件下载到客户端系统中的特定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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