ASP
  Home arrow ASP arrow Page 5 - Getting Remote Files With ASP
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Getting Remote Files With ASP
By: Justin Cook
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 58
    2005-08-09

    Table of Contents:
  • Getting Remote Files With ASP
  • The Concept
  • The Code Client Script Initialization
  • PerformUpdate() Explained
  • WriteFile() Explained

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Getting Remote Files With ASP - WriteFile() Explained


    (Page 5 of 5 )

    There is nothing fancy about how we tell if a file is binary or text. We just look at the extension. Remember that we passed the file name in the PATH XML node.

    Notice that with binary files, we are using the XML nodeTypedValue rather than the Text property. This property returns the data in whatever type it was set as on the server side (see the server code below). Since the server code sets all binary files as “bin.base64”, the client will then read the data in as Base64 encoded. Remember that the XML that is being passed also holds status data, such as the type.

    The WriteFile() subroutine uses ADO to write our binary files. We can use normal text-based FSO operations for the .txt and .asp files. Here’s the meat of the routine, doing the actual saving work:

    If ( iType = C_BINARY ) Then

          Set objBinaryStream = CreateObject("ADODB.Stream")

          objBinaryStream.Type = adTypeBinary

          objBinaryStream.Open

          objBinaryStream.Write vData

          objBinaryStream.SaveToFile (sDestPath & sFileName), adSaveCreateOverWrite

          Set objBinaryStream = Nothing

    Else

    Set fileWriteFile = fsoFileObject.OpenTextFile(sDestPath & sFileName, 2, True)

    fileWriteFile.Write vData

          fileWriteFile.Close

          Set fileWriteFile = Nothing

    End If

    IMPORTANT: Make sure the final destination on the client has WRITE rights granted to the IUSR_computername account or the write will fail. To make this more robust, you can test permissions with an ON ERROR trap. Write a dummy file to the destination path. If an error is generated, you can display a nice message to the client, and send a message back to the server, telling the administrator that the update failed.

    Conclusion

    In this first of two articles, we saw how to connect to a remote server, retrieve text and encoded binary files, and save them locally. In the next article, we will see how to process the request on the server side to actually send the files. Here’s a link to the full working client script, and the two images referenced:

    [http://images.devshed.com/af/stories/Getting Remote Files with ASP/Client.zip]

    To see this in action, check out Mall23 auto-update feature (it’s pretty impressive!):  http://www.mall23.com/store/?vf=14


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Getting Remove Files is very nice article. But It will be so good if the screen...
     

    ASP ARTICLES

    - ADO for the Beginner
    - ADO.NET 101: Data Rendering with a DataGrid ...
    - Introducing SoftArtisans OfficeWriter 3.0 En...
    - Getting Remote Files With ASP
    - The Real Basics of Functions in ASP
    - Enhancing Readability with ASP
    - Mimicking PHP's String Formatting Functions
    - Windows Server Hacks 12, 77, and 98
    - How to Sort a Multi-Dimensional Array
    - Developing an Information Management Tool wi...
    - What are Active Server Pages?
    - Getting Remote Pages with ASP
    - FTP’ing Files with ASP
    - Apply Single-Sign-On to Your Application
    - Easy Error Management

    Iron Speed




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway