 |
| Javascript How-To Ask your "How do I do this with Javascript?" questions here. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 23rd, 2004, 05:32 AM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to show a File Dialog using Javascript
Dear All,
how to show a file dialog "Save As" window for selecting the location and to write a .txt file on the specified location without using ActiveXObject.. scripting.filesystemobject and MsComDlg
URGENT
Thanks in advance
|
|

June 23rd, 2004, 06:38 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Try:
document.execCommand("saveas",false,"c:\\where\\yo u\\want\\to\\save\\it\\to.txt");
HTH,
Snib
<><
|
|

October 14th, 2007, 10:45 PM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi All,
How to open file dialog box using java script.
with help of <input type="file" /> I can open the file dialog box..
but my requirement is to open the file dialog box on click of link?
Pls help me out solving this problem..
sheetal
|
|

October 16th, 2007, 04:38 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi SheetM!!
Hope this will help you
<script>
function openFileOption()
{
document.getElementById("file1").click();
}
</script>
<input type="file" id="file1" style="display:none">
<a href="#" onclick="openFileOption();return;">open File Dialog</a>
Cheers :)
vinod
|
|

October 16th, 2007, 04:54 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Vindo..
I am using the JSF framework.. So I am using the JSF component for file dialog
<hx:fileupload id="fileupload1"
styleClass="fileupload" accept="image/*"
binding="#{photoGalleryEditPhotoBean.photoName}"></hx:fileupload>
It same as could as the <Input type="file"/>
I wrote the same javascript to display the dialog on click of link.
When the form is submited then the selected file path is getting cleared.
Bcoz of this I am not able to proceed the futher..
Do you know wt could be the reason..
sheetal
|
|

October 16th, 2007, 05:14 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Yes, it's a security thing. Otherwise you could arrange for a file to be uploaded without the user's full knowledge.
--
Joe ( Microsoft MVP - XML)
|
|

July 9th, 2008, 06:25 PM
|
|
Registered User
|
|
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

July 9th, 2008, 06:28 PM
|
|
Registered User
|
|
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

May 28th, 2011, 05:41 AM
|
|
Registered User
|
|
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
saving in different format
Quote:
Originally Posted by Snib
Try:
document.execCommand("saveas",false,"c:\\where\\yo u\\want\\to\\save\\it\\to.txt");
HTH,
Snib
<><
|
thanks this code is working fine. But it only gives the oppertunity to save either in .txt format or a webpage format.
what if i want to save it in other formats like .doc,.docx,.pdf etc.....
|
|

June 15th, 2011, 11:59 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
how to select & browse files with dialog box
hihi! I'm new in javascripts. I wanna to find out how to select & browse files in all browser as I doing my projects. I need help on this thanks. Did anyone know how? 
|
|
 |