Reputation: 11398
I'm trying to implement a file upload system and I don't really get what to do.
I'm looking for the easiest way to do it. After long researches, I've found those explanations.
forums.asp.net/t/1678157.aspx/2/10
So, here is the things I've done inside the view :
@Code
Dim fileName As String = ""
If (IsPost) Then
Dim uploadedFile = Request.Files(0)
fileName = Path.GetFileName(uploadedFile.FileName)
fileSavePath = Server.MapPath("~/Content/Uploads/" + fileName)
uploadedFile.SaveAs(fileSavePath)
End If
End Code
<form action="" method="post">
@FileUpload.GetHtml(
initialNumberOfFiles := 1,
allowMoreFilesToBeAdded := False,
includeFormTag := True,
uploadText := "Upload")
</form>
Problem : GetHtml is not a member of 'System.Web.UI.WebControls.FileUpload' What can I do to fix this? Is it the good way to handle file uploads?
Upvotes: 0
Views: 1839
Reputation: 9271
One problem can be, because you forgot the enctype="multipart/form-data"
in your form post.
Then maybe your Upload plugin is not installed correctly. I assume your are using WebMatrix, so this article can be of help
Upvotes: 1
Reputation: 22867
Scott Hanselman has a great article on implementing this here
The code is in C# but it should get you started
Upvotes: 1