HTML入门 带上传功能的录入界面介绍如下:
HttpRequest事件代码很简单:Select Case e.Path
Case "AddNew.htm"
If e.PostValues.Count = 0 AndAlso e.Files.Count = 0 Then
Dim sb As New StringBuilder
sb.AppendLine("<form enctype='multipart/form-data' action='AddNew.htm' method='post' id='form1' name='form1'>")
sb.AppendLine("姓名: <input name='xm' id='xm'><br/><br/>")
sb.AppendLine("部门: <input name='bm' id='bm'><br/><br/>")
sb.AppendLine("职务: <input name='zw' id='zw'><br/><br/>")
sb.AppendLine("学历: <input name='xl' id='xl'><br/><br/>")
sb.AppendLine("照片: <input type='file' name='zp' id='zp' multiple><br/><br/>")
sb.AppendLine("<input Type='submit' name='Sumbit' id='Sumbit' value='确定'>")
sb.AppendLine("</form>")
e.WriteString(sb.ToString)
Else
Dim dr As DataRow = DataTables("员工").AddNew()
Dim inms() As String = {"xm","bm","zw","xl"} '输入框名称数组
Dim cnms() As String = {"姓名","部门","职务","学历"} '列名数组,注意列名和输入框必须一一对应,位置不能错乱
For i As Integer = 0 To inms.Length -1
dr(cnms(i)) = e.PostValues(Inms(i))
Next
If e.Files.ContainsKey("zp") Then
dr("照片") = e.Files("zp")(0)
e.SaveFile("zp", e.Files("zp")(0), ProjectPath & "Attachments\" & e.Files("zp")(0))
End If
dr.Save()
Dim sb As New StringBuilder
sb.AppendLine("增加记录成功! <br/><br/>")
sb.AppendLine("<a href='AddNew.htm'>继续增加</a>")
e.WriteString(sb.ToString)
End If
End Select
其中介绍了照片的保存方法。如果使用的云服务器,在手机上或者某个客户端上,用这种方法可以把照片直接保存到指定目录么?谢谢!