Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Closed Thread
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-02-2005, 06:23 PM   PM User | #1
tripwater
Regular Coder

 
Join Date: May 2005
Posts: 262
Thanks: 4
Thanked 0 Times in 0 Posts
tripwater is an unknown quantity at this point
Raising "save as" dialog

Hello,

I have a web project that tracks warehouse inventory. THey want to be able to print barcodes for scanning. I wanted to originally generate the file and write it to the client's HD and if possible raise the print dialog automatically to print them. They do high volume so I need this to be as streamline as possible.

Before anyone chimes in with "Malicious malware", save your breath please.

I found this post on a forum :

Quote:
There are valid and legitimate reasons for wanting to write to the visitors harddrive. However, the only secure and acceptable method of doing so is to use server-side code to send an HTTP attachment to the browser and let the browser raise the Save As dialog box to ask the visitor where they would like to write the file. At that point, of course, the visitor has the right to refuse the file altogether.

I would be fine with this. If I can take a file, generate it and have the save as dialog pop up automatically, giving them the ability to save it to their HD that would be fine. How do I do this? At this point I can generate a text or html file for this purpose. But I do not know how to send an HTTP attachment to the browser and let the browser raise the Save As dialog box. I am using php FYI.

If you have a better approach that does not involve a bunch of extra steps for the user, I am all ears. If I can not do this, then I will be forced to write the file on the server, then have a program running on the client's machine checking for files on the server. I would rather not have to do this. Again they want this functionality and it is an internal application so they are aware of the security issues.

Thank you for any help with this.
tripwater is offline  
Old 06-02-2005, 06:45 PM   PM User | #2
SpirtOfGrandeur
Regular Coder

 
Join Date: May 2005
Location: Michigan, USA
Posts: 566
Thanks: 0
Thanked 0 Times in 0 Posts
SpirtOfGrandeur is an unknown quantity at this point
You have to change the context headers... using PHP. This is not a JS question. But i will answer it in ASP because that is what i know I know it is easy to change to PHP though

Code:
Response.ContentType = "application/x-download"		
Response.AddHeader "content-disposition","attachment; filename=" & fileName & ".xls"
SpirtOfGrandeur is offline  
Old 06-02-2005, 06:50 PM   PM User | #3
tripwater
Regular Coder

 
Join Date: May 2005
Posts: 262
Thanks: 4
Thanked 0 Times in 0 Posts
tripwater is an unknown quantity at this point
Thank you for your reply. Since I do not know asp and I am trying something I have never done before, could you give me an idea of what I could type into google to find the php version of what you gave me?

Thanks alot
tripwater is offline  
Old 06-02-2005, 06:56 PM   PM User | #4
Harry Armadillo
Regular Coder

 
Join Date: Feb 2005
Posts: 400
Thanks: 0
Thanked 0 Times in 0 Posts
Harry Armadillo is on a distinguished road
http://us4.php.net/manual/en/function.header.php
Harry Armadillo is offline  
Old 06-02-2005, 06:57 PM   PM User | #5
tripwater
Regular Coder

 
Join Date: May 2005
Posts: 262
Thanks: 4
Thanked 0 Times in 0 Posts
tripwater is an unknown quantity at this point
Thanks
tripwater is offline  
Old 06-02-2005, 08:12 PM   PM User | #6
WA
Administrator


 
Join Date: Mar 2002
Posts: 2,596
Thanks: 2
Thanked 19 Times in 18 Posts
WA will become famous soon enough
Topic continued in PHP category: http://www.codingforums.com/showthread.php?t=60315 Closing this one.
__________________
- George
- JavaScript Kit- JavaScript tutorials and 400+ scripts!
- JavaScript Reference- JavaScript reference you can relate to.
WA is offline  
Closed Thread

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:42 AM.


Advertisement
Log in to turn off these ads.