Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
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
 
Old June 23rd, 2004, 05:32 AM
Registered User
 
Join Date: Nov 2003
Location: coimbatore, tN, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old June 23rd, 2004, 06:38 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Try:

document.execCommand("saveas",false,"c:\\where\\yo u\\want\\to\\save\\it\\to.txt");

HTH,

Snib

<><
 
Old October 14th, 2007, 10:45 PM
Authorized User
 
Join Date: Sep 2006
Location: pune, Maharastra, India.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old October 16th, 2007, 04:38 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

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
 
Old October 16th, 2007, 04:54 AM
Authorized User
 
Join Date: Sep 2006
Location: pune, Maharastra, India.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old October 16th, 2007, 05:14 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old July 9th, 2008, 06:25 PM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please check
http://www.ardentedge.com/pr_fd.htm


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

Please check
http://www.ardentedge.com/pr_fd.htm

 
Old May 28th, 2011, 05:41 AM
Registered User
 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default saving in different format

Quote:
Originally Posted by Snib View Post
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.....
 
Old June 15th, 2011, 11:59 PM
Registered User
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?




Similar Threads
Thread Thread Starter Forum Replies Last Post
LinkButton should not show javascript in Statusbar savan_thakkar ASP.NET 1.0 and 1.1 Professional 2 August 27th, 2006 06:25 AM
hide/show header with javascript crmpicco Javascript How-To 2 April 10th, 2006 03:45 AM
Javascript Confirm dialog difficulty ayrton Javascript 1 May 20th, 2005 03:34 AM
Modal Dialog (javascript & ASP.NET) nestor082 ASP.NET 1.0 and 1.1 Basics 2 March 30th, 2005 08:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.