www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > .NET

    .NET Discussion and technical support for, building, using and deploying .NET sites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 03-16-2007, 01:53 PM
    paradise_wolf paradise_wolf is offline
    Registered User
     
    Join Date: Aug 2006
    Posts: 25
    Best strategy for allowing a customer to download a file

    The usual code for downloading files allows the customer
    to choose which folder ( in his computer ) he wants the
    application to download to :
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    FileStream MyFileStream =
    new FileStream(@"E:\X-102.pdf", FileMode.Open);
    long FileSize;
    FileSize = MyFileStream.Length;
    byte[] Buffer = new byte[(int)FileSize];
    MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
    MyFileStream.Close();
    Response.ContentType = "application/pdf";
    Response.AddHeader
    ("content-disposition", "attachment; filename= X-102.pdf ");
    Response.BinaryWrite(Buffer);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    But the problem with this code is that you cannot
    know if the customer finished successfully the
    download and then use it as flag to trigger other
    functionalities.

    I have an alternative code for downloading a file that
    allows me to control the download process and even
    display it through a progress bar.

    But it lacks the capability to allow the customer to
    browse his computer and locate a convenient folder
    to download the file like the first method.

    I am building a web site where some customers, after
    having logged in with special privileges, they could
    then access a special page where they would be able
    to download pdf files.

    I would like to give them the capacity to choose
    where ( which folder ) to download the pdf file in
    their computers.

    I wanted to use the following javascript code for
    this purpose:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <script language=javascript>

    <!--

    function GetDownloadPath()
    {
    var frm = document.forms[0];
    var Shell = new ActiveXObject("Shell.Application");
    var Folder = new Object;

    Folder = Shell.BrowseForFolder
    (0, "Choose a download folder", 0);

    var FolderItem = new Object;
    FolderItem = Folder.Items().Item();
    }
    -->
    </script>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    But someone told me that it only works on IE –and-
    additionally, this code only works when it runs from
    within a web site whose URL address starts with
    “https” instead of “http”. Furthermore, it has to be
    listed within “Trusted Sites” in the customer’s
    IE Security settings and his computer should enable
    ActiveX controls.

    So, it seems that this method is a bit tricky and it
    would alienate customers who either have different
    internet browsers or do not enable ActiveX
    controls in their computers.

    Another option is to set my application with a
    default path “C:\” assuming that every customer
    would have this basic drive and add a TextBox
    control where the customer could type an
    alternative path. But then I would need a method
    to verify if the customer typed a correct path.

    Please I need the opinion of the experts to
    suggest me which one is the best method or
    even suggest me a better one.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes 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 Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:04 AM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.