.NET
  Home arrow .NET arrow HTTP File Upload without User Interaction ...
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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? 
.NET

HTTP File Upload without User Interaction using .NET
By: Chandru Prashanth
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 28
    2004-10-26

    Table of Contents:
  • HTTP File Upload without User Interaction using .NET
  • Solution
  • Explanation of Code for Upload Function
  • CAB File

  • 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


    HTTP File Upload without User Interaction using .NET


    (Page 1 of 4 )

    This article aims to teach users how to upload files by using .NET without getting messy, as can happen with HTTP. The author looks at possible solutions and explains why they do not work, then goes on to outline his solution.

    Introduction

    This article addresses the problem of uploading a file without user interaction, similar to an article I previously wrote, "HTTP File Download without user interaction using .NET". Most of the upload code available depends on the user to browse his or her hard disk to select the file (based on RFC1867), and it doesn’t display a progress bar while uploading it to the server. This article provides an appropriate solution for it.

    Concept

    The idea is to have an ActiveX control (for other alternatives, read the download article noted above) read the file from the client's hard disk and write it into the Request stream of HTTP. The ASP.NET code on the server will read the file content from the Request stream and write it into the hard disk.

    About ActiveX Control

    The term 'ActiveX' refers to an extension of existing OLE and COM technologies. An ActiveX control is an object that supports a customizable, programmatic interface. Using the methods, events, and properties exposed by a control, Web authors can automate their HTML pages. Examples of such controls include text boxes, command buttons, audio players, video players, stock tickers, and so on.

    The following are the possible solutions which can be used to solve our problem.

    1. INET control - This is an ActiveX control provided by Microsoft for Internet transfer of files. We can read the file contents into a string and send it as POST data using the function Execute provided by the control. If all you want to do is upload the file, then this method should suffice, but if you want to display the progress as well, then this solution can't be used as it doesn’t provide the number of bytes being uploaded.

    2. Wininet dll - This DLL contains a set of APIs provided by Microsoft for Internet transfer of files. Performance is better in this case since we are directly using the APIs and not relying on another control to provide the functionality. This is the DLL which I used for downloading the file but sadly for uploading the file, it has a bug (it always returns 0 when it should return 1) in its InternetWriteFile function.

    3. Winsock control - This is an ActiveX control provided by Microsoft for network programming. It uses sockets to connect to the server and get the files. It’s a low level control where the programmer has to do the bulk of the work, but luckily it provides sendProgress event which gives information about the number of bytes uploaded. So we would be using this control to solve our problem.

    More .NET Articles
    More By Chandru Prashanth


       · Interesting approach. There are two questionsa) Why not use a stream, so you don't...
       · Yes, it is not as simple as the author has presented here in this ariticle...The...
       · I cant put my finger on a specific problem, however getting INET or winsock controls...
       · DITTO ALL THE WAY!
       · I'm trying to convert this code to C# but I'm having some trouble...For one I'm...
       · Hi Mr. Chandru,I tried using this code, although I used a third party winsock...
     

    .NET ARTICLES

    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC
    - The Windows Ribbon Framework
    - Markup Language for the Ribbon Framework
    - Visually Upgrade Your MFC Project
    - New Features for the Statusbar in MFC
    - Working with the Statusbar in MFC
    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek