473,732 Members | 2,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

uploading using https

greetings,

i need to upload an .xls file using a secure connection. so i though of using https...
can i know how this can be done?
Nov 18 '05 #1
1 1844
The <INPUT TYPE=FILE> tag creates a file upload object with a text box and
Browse button. Users can enter a file path in the text box or click the
Browse button to browse the file system. The INPUT type=file element must
be enclosed within a FORM element.

A value must be specified for the NAME attribute of the INPUT type=file
element.

The METHOD attribute of the FORM element must be set to post.

The ENCTYPE attribute of the FORM element must be set to
multipart/form-data.

On the server side you would reference the file using the Request.Files
object. Here is a sample.

First I created a text file with the contents "Hello, World!" and saved
that to disk. Then I created a new project using ASP.NET. Here is my HTML
page:

<%@ Page language="c#" Codebehind="Def ault.aspx.cs" AutoEventWireup ="false"
Inherits="FileU pload._Default" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Defaul t</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio 7.0">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5";>
</HEAD>
<body>
<form id="Default" method="post" runat="server"
enctype="multip art/form-data">
<INPUT type="file" runat="server" id="File1" name="File1">
<INPUT
id="Submit1" type="submit" value="Submit" name="Submit1" runat="server">
</form>
</body>
</HTML>

And here is my codebehind page:

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

namespace FileUpload
{
/// <summary>
/// Summary description for _Default.
/// </summary>
///
public class _Default : System.Web.UI.P age
{
protected System.Web.UI.H tmlControls.Htm lInputFile File1;
protected System.Web.UI.H tmlControls.Htm lInputButton Submit1;

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here

string MyString = "";
int loop1;
int FileLen;
HttpFileCollect ion Files;
HttpPostedFile thisFile;
System.IO.Strea m myIS;
Files = Request.Files; // Load File collection into
HttpFileCollect ion
variable.
for(loop1=0; loop1<Files.Cou nt;loop1++)
{
thisFile = Request.Files[loop1];
Response.Write( "<b>"+thisFile. FileName+"</b><br>");

FileLen = thisFile.Conten tLength;
byte[] input = new byte[FileLen];

// Initialize the stream.
myIS = thisFile.InputS tream;
myIS.Read(input , 0, FileLen);

// Copy the byte array into a string.
for (int Loop1 = 0; Loop1 < FileLen; Loop1++)
MyString = MyString +(char)input[Loop1];

Response.Write( MyString+"<br>< br>");

}

}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Submit1.Se rverClick += new
System.EventHan dler(this.Submi t1_ServerClick) ;
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void Submit1_ServerC lick(object sender, System.EventArg s e)
{

}
}
}

You browse to the file with the form, and upload it. On the server side you
can get at the file using the Request.Files object, you can access the file
name, and the contents are in the stream.

Hope this helps!
"Asha" <As**@discussio ns.microsoft.co m> wrote in message
news:1C******** *************** ***********@mic rosoft.com...
greetings,

i need to upload an .xls file using a secure connection. so i though of using https... can i know how this can be done?

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7836
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of files via FTP. I'm using ftplib to do it, and for each file I'm using transfercmd("STOR " + myfile) to get the socket, then uploading 4096 bytes at a time and providing status updates via a GUI interface. Finally, I close the socket, set it to...
2
4979
by: rbt | last post by:
Has anyone used pure python to upload files to a webdav server over SSL? I have no control over the server. I can access it with all of the various webdav GUIs such as Konqueror, Cadaver, etc. by using a URL like this: webdavs://dav.hostname.com/user_name/uploads My goal is to upload files automatically with a python script. The server requires authentication over SSL which I can do with urllib2 like this:
2
2417
by: news microsoft | last post by:
Hello all, In my ASP.Net , C# web Application I have used the traditional upload code i.e. HTTP Method and it works fine for files and images up to 5 MB but once the size of file is more than 5 MB it gives a error mostly time out error and also uploading sound files (.mp3, .wma, .dat) is not allowed.
13
4317
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
0
7280
by: Alex | last post by:
my app was working fine in VB.NET 2003 (and framework 1.1). Now with VB.NET 2005 (framework 2.0) the uploading to an http server (ie. www.sharebigfile.com) stops with the error "The request was aborted: The request was canceled" after about 7 MB. For example, I might be uploading a 73MB file. After about 11% done the upload aborts. :shake: It works great for files < 5MB. I can upload those every time.
1
2826
by: dmbkiwi | last post by:
I've been using urllib2 to try and automate logging into the google adsense page. I want to download the csv report files, so that I can do some analysis of them. However, I don't really know how web forms work, and the examples on the python.org/doc site aren't really helpful. I've found working scripted login code using javascript, but I don't speak javascript. These are the relevant functions:
0
10710
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I am using Apache server/Linux platform and started server with "server certificate". I configured server to listen HTTPS service at port 443. I downloaded download.txt correctly from server using command as $curl --cacert cacert.pem ...
0
816
by: ValK | last post by:
Hi I need to upload large tif/pdf files to the server over https. Is anybody can point me to the right direction? Also, I heard that WebDav may be an option. Couldn't fine any usefull information on this. Thanks
0
1539
by: Paul.Hawkes | last post by:
All I'm having trouble getting the following to work. I have been able to download and delete a file with the same credentials and similar code, but when I try upload the file. I get a returned error of "The Remote server returned an error: (500) Internal Server Error." from the SPS. Is there something that must be set up on SPS to allow a "PUT" or am I missing something. I am using very similar code to delete and download a file...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.