how to download a file without opening file download dialog box

Reply

Join Date: Oct 2007
Posts: 85
Reputation: hidash_in has a little shameless behaviour in the past 
Solved Threads: 0
hidash_in's Avatar
hidash_in hidash_in is offline Offline
Junior Poster in Training

how to download a file without opening file download dialog box

 
0
  #1
Nov 21st, 2007
<a onclick=" window.open('C:/Documents and Settings/palanikumar.r/Desktop/Doc.bat','remarks','height=600,width=915,left=50,top=50')" ><input type="button" value="start" onClick="startclock('')"></a>
see, in the above coding i am using button to open a document file.
im opening it through the batch file..
the batch file contains

@echo off
c:
cd\
cd jdk1.5.0_05\bin
javac Doc.java
java Doc

Doc.java is a java program through this java program i am opening a word application

import java.io.*;

public class Doc
{
public static void main(String[] str)throws IOException
{
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "C:\\Program Files\\Microsoft Office\\OFFICE11\\WINWORD.exe");
}
}

when i clicking the button in the html file the batch file runs first and it calls the java program and then the word application open.
And my problem is when i am clicking the button the batch program is called at that time the file download dialog box is opening.

i dont want to open the dialogue box.
if possible pls help.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,358
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: how to download a file without opening file download dialog box

 
0
  #2
Nov 21st, 2007
You are getting a download box, because the browser (I assume your on Windoof) does not know what to do with files that have an extension of ".bat", so it is asking you what it should do with it. You need to add a mime type for ".bat".

This entire action, is, however, wrong on so many levels (technical, practical, and security levels) that I cannot even begin to list them.

Edit: Or a mime type exists, but its action is save/download, in which case you simply need to cahgne the mime type. But see my above comment.

And, on a side note, why did you open a new thread for this, rather than simply replying to my post in your other thread?
Last edited by masijade; Nov 21st, 2007 at 6:24 am.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC