Friday, July 17, 2009

File Uploading in .NET

Hi,
Viewers ,
This is my first Post and I have started with .NET File uploading

1.
2. Sub Upload(Source As Object, e As EventArgs)
6.
7. If Not (myFile.PostedFile Is Nothing) Then
8.
9. Dim intFileNameLength as Integer
10. Dim strFileNamePath as String
11. Dim strFileNameOnly as String
12.
13. 'Logic to find the FileName (excluding the path)
14. strFileNamePath = MyFile.PostedFile.FileName
15. intFileNameLength = Instr(1, StrReverse(strFileNamePath), "\")
16. strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath)-intFileNameLength)+2)
17.
18. 'myFile.PostedFile.SaveAs("c:\inetpub\wwwroot\yourwebapp\upload\" & strFileNameOnly)
19. myFile.PostedFile.SaveAs("d:\" & strFileNameOnly)
20. lblMsg.Text = "File Upload Success."
21.
22. End If
23. End Sub
24.
26.
27.
28.
29.

File Upload


30.
31.

32. File:
33.
34.
35.

36.
37.
38.

1 comment: