1
我怎樣才能上傳視頻在我的MySQL數據庫使用asp.net mvc?如何上傳視頻在asp.net mvc
觀點:
<form method="post" enctype="multipart/form-data" action="<%=url.action("VideosInsert") %>">
<%Using Html.BeginForm%>
<p>
<label for="videourl">Browse url :</label>
<input type="file" name="video" />
</p>
<p>
<label for="caption">Caption :</label>
<%=Html.TextBox("caption", String.Empty, New With {Key .size = 100})%>
</p>
<p>
<label for="eventDate">Date of Event:</label>
<%=Html.TextBox("eventDate")%>
</p>
<p>
<label for="category">Category :</label>
<%=Html.TextBox("category")%>
</p>
<p>
<%=Html.CheckBox("feature")%>
<label for="feature">Feature</label>
</p>
<input type="submit" name="uploadvideo" value="Upload Video" />
<%End Using%>
</form>
控制器:
進口System.IO
Public Class AdministrationController
Inherits Global.System.Web.Mvc.Controller
Private dVideos As New ClassVideosConnection
<AcceptVerbs(HttpVerbs.Post)> _
Function VideosInsert(ByVal video As HttpPostedFileBase, ByVal caption As String, ByVal eventDate As String, ByVal category As Integer, ByVal feature As Boolean) As ActionResult
//the code goes here, i think
dVideos.videoInsert(url:=video.FileName, caption:=caption, eventDate:=eventDate, IDcat:=category, featured:=dfeature)
Return View()
End Function
End Class
型號:
Imports Microsoft.VisualBasic
Imports System.Data
Public Class ClassVideosConnection
Inherits ClassConnection
Public Sub videoInsert(ByVal url As String, ByVal caption As String, ByVal eventDate As Date, ByVal IDcat As Integer, ByVal featured As Integer)
Dim insert As String = String.Format("INSERT INTO videos(vidURL, vidCaption, vidEvent, IDcategory, vidFeatured) VALUES ('{0}','{1}','{2}','{3}','{4}')", url, caption, eventDate, IDcat, featured)
UpdateData(insert)
End Sub
End Class
我不知道這是否是正確的,但這種是我們的語法編輯上傳圖片.. 預先感謝您!
我只想擺脫Html.BeginForm(的)和結束使用。
更清楚我。 – 2009-10-10 00:41:30