Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    262
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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 :

    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.

  • #2
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    262
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    262
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks

  • #6
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •