Using asp.net to design ftp file upload (simple front code)

Source: Internet
Author: User
Tags end file size file upload ftp ftp file net string
Asp.net| Upload | Design |asp.net| upload <% @ Import namespace= "System.IO"%>
<body >
<script LANGUAGE = "VB" RUNAT = "SERVER" >
Sub uploadfile_clicked (Sender as Object, e as EventArgs)
Dim Lstrfilename As String
Dim Lstrfilenamepath As String
Dim Lstrfilefolder As String
' If the upload directory is empty, use ' C:\ "As the default upload directory
' Get the directory name uploaded to the server
If Dir.value <> "" Then
Lstrfilefolder = Dir.value
Else
Lstrfilefolder = "C:\"
End If

' Get file name
Lstrfilename = LoFile.PostedFile.FileName
' Note: LoFile.PostedFile.FileName returns the
File name selected through the file dialog box, which contains the directory information for the file
Lstrfilename = Path.getfilename (lstrfilename)
' Remove directory information, return file name

' To determine whether an uploaded directory exists or not, to establish
If (not directory.exists (Lstrfilefolder)) Then
Directory.CreateDirectory (Lstrfilefolder)
End If

' Uploading files to the server
Lstrfilenamepath = Lstrfilefolder & Lstrfilename
' Get uploaded directory and file name
LoFile.PostedFile.SaveAs (Lstrfilenamepath)

' Get and display the properties of the uploaded file
Filename.text = Lstrfilename
' Get file name
Filetype.text = LoFile.PostedFile.ContentType
' Get file type
Filelength.text = CStr (loFile.PostedFile.ContentLength)
' Get file length
Fileuploadform.visible = False
Answermsg.visible = True
' Show upload file properties
End Sub
</script >
<asp:panel id = "Fileuploadform" visible = "true" runat = "server" >
<form method = "POST" enctype = "multipart/form-data" runat = "server" >

Please select the name of the file to upload to the server:
<input id = "Lofile" type = "file" runat = "server" > <BR >
Please enter the name of the directory to upload to the server:
<input id = "dir" type = "text" runat = "server" > <BR
<input type = "submit" value = "start uploading" OnServerClick = "
uploadfile_clicked "runat =" server ">
<BR >
</form >
</asp:panel >

<asp:panel id = "answermsg" visible = "false" runat = "server" >
Thank you for using ASP.net page to implement file upload <BR >
Successfully uploaded <asp:label id = "FileName" runat = "server"/> <BR
File size <asp:label id = "Filelength" runat = "server"/> byte <br > file type <asp:label id = "FileType" runat = "server"/> <BR
</asp:panel >
</body >




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.