Using asp.net to design ftp file uploads (asp.net)

Source: Internet
Author: User
Tags ftp ftp file net visual studio
Asp.net| Upload | Design |asp.net| upload this version and the simple front of the class is like a function, but the front end of the code to split the

. aspx
<%@ Page language= "vb" autoeventwireup= "false" codebehind= "WebForm6.aspx.vb" inherits= "MYDATA.WEBFORM6"%>
! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title>webform6</title>
<meta name= "generator" content= "Microsoft Visual Studio. NET 7.1" >
<meta name= "Code_language" content= "Visual Basic. NET 7.1" >
<meta name= "vs_defaultClientScript" content= "JavaScript" >
<meta name= "vs_targetschema" content= "http://schemas.microsoft.com/intellisense/ie5" >
<body ms_positioning= "GridLayout" >
<asp:panel id= "Fileuploadform" visible= "true" runat= "Server" >
<form id= "Form2" method= "post" enctype= "Multipart/from-data" runat= "Server" >
<p><input id= "Lofile" type= "file" Name= "Lofile" runat= "Server" ></P>
<p>
<asp:textbox id= "dir" runat= "Server" ></asp:TextBox><BR><!--can specify the route path-->
<asp:button id= "Button1" runat= "Server" text= "button" ></asp:Button><BR>
</p>
</form>
</asp:panel>
<asp:panel id= "Answermsg" visible= "false" runat= "Server" >
<asp:label id= "FileName" runat= "Server" ></ASP:label>
<br>
<asp:label id= "filelength" runat= "Server" ></ASP:label>
<br>
<asp:label id= "FileType" runat= "Server" ></ASP:label>
<br>
</asp:panel>
</body>

. vb
Imports System.IO
Imports System.Data

Public Class WEBFORM6
Inherits System.Web.UI.Page

#Region "webフォームデザイナで Generation されたコード"

' この call び out しはwebフォームデザイナで necessary です.
<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()

End Sub
Protected WithEvents Fileuploadform as System.Web.UI.WebControls.Panel
Protected WithEvents FileName as System.Web.UI.WebControls.Label
Protected WithEvents Filelength as System.Web.UI.WebControls.Label
Protected WithEvents FileType as System.Web.UI.WebControls.Label
Protected WithEvents answermsg as System.Web.UI.WebControls.Panel
Protected WithEvents Lofile as System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents Button1 as System.Web.UI.WebControls.Button
Protected WithEvents dir as System.Web.UI.WebControls.TextBox

' メモ: のプレースホルダ declaration はwebフォームデザイナで necessary です.
' Removes the および movement しないでください.
Private Designerplaceholderdeclaration as System.Object

Private Sub Page_Init (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Mybase.init
' codegen:このメソッド call び out しはwebフォームデザイナで necessary です.
' コードエディタを makes って becomes more しないでください.
InitializeComponent ()
End Sub

#End Region

Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
' ページを initial するユーザーコードをここに 挿 into します.
End Sub

Private Sub button1_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
Dim Lstrfilename as String
Dim Lstrfilenamepath as String
Dim Lstrfilefolder as String

If dir. Text <> "Then ' If the registration is empty, use" c:\ "As the default of the traditional registration
Lstrfilefolder = dir. Text ' Get the name of the registration that was uploaded to the service
Else
Lstrfilefolder = "C:\"
End If

Dim files as System.Web.HttpFileCollection = System.Web.HttpContext.Current.Request.Files
Dim PostedFile as System.Web.HttpPostedFile = files (0)

Lstrfilename = System.IO.Path.GetFileName (postedfile.filename) ' Got the filename
' Note: LoFile.PostedFile.FileName returns the file name that is selected through the file dialog box, which contains the document's target registration information

Lstrfilename = Path.getfilename (lstrfilename) ' Remove eye registration information, return file name

if (not directory.exists (lstrfilefolder)) Then ' judge whether the presence of the registration or not exists, it is established
Directory.CreateDirectory (Lstrfilefolder)
End If

Lstrfilenamepath = lstrfilefolder & Lstrfilename ' upload files to the service
LoFile.PostedFile.SaveAs (Lstrfilenamepath) ' Get the name of registration and file

' Gain and display the attributes of the document



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.