开发者

Download multiple files when form submitted

I currently submit a form on to an invisible iframe. The action file creates a CSV which is automatically d开发者_StackOverflowownloaded. Is it possible to have multiple files downloaded when the form is submitted?


I don't think that it is possible to do without having a custom download manager on the client side. You could technically insert them into the response stream to the client, but they wouldn't understand how to handle it.

I have always just created a zip file with all the files in it and sent that to the client. Wouldn't work if you are trying to display them in the browser or something like that, but I don't know what your goal is on the client so I thought that it might work for you.


Yes, the following code does what you want, with some modification. Note, very much not my code and it requires javascript be enabled.

function makeFrame( url ) 
{ 
    ifrm = document.createElement( "IFRAME" ); 
    ifrm.setAttribute( "style", "display:none;" ) ;
    ifrm.setAttribute( "src", url ) ; 
    ifrm.style.width = 0+"px"; 
    ifrm.style.height = 0+"px"; 
    document.body.appendChild( ifrm ) ; 
}  

function downloadFiles( )
{
   makeFrame('urlof/file1.csv');
   makeFrame('urlof/file2.csv);
}


No, that is not possible. Each response can only contain one file. You need one request for each file that you want to download.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜