up.asp代碼:
<%@ Language=vbscript %>
<!--#include file="errorclass.asp"-->
<!--#include file="class.asp"-->
<html><head><title>FileList</title></head>
<%
On Error Resume Next
Dim fc_Class,ec_Class
Dim UpUser,JzName,CsName,Path,Remark,Action
Set fc_Class = New MBClass
Set ec_Class = New ErrorClass
Action = ""
Action = Trim(Request.QueryString("action"))
If Action = "1" Then
If getForm() = 1 Then
If path<>"" Then
upFile(Path)
End If
Call fc_Class.addmb(UpUser,JzName,CsName,GetFileName(Path),Remark)
If ERR.number = 0 Then
ec_Class.Message = ec_Class.Message&"錄入成功<br>"
Call ec_Class.showMessage("mbbk.asp","成功")
Else
ec_Class.Founderr = True
ec_Class.Message = ec_Class.Message&"錄入數據時失敗<br>"
Call ec_Class.showMessage("mbbk.asp","失敗")
End If
Else
Call ec_Class.showMessage("mbbk.asp","校驗失敗")
End If
End If
Function upFile(filepath)
if request.form("path")<>"" then
filepath = Request.Form("path")
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 1 ' adTypeBinary
objStream.Open
objStream.LoadFromFile filepath
objStream.SaveToFile "d:\file\MB\"&GetFileName(filepath),2
objStream.Close
If ERR.number = 0 Then
ec_Class.Message = ec_Class.Message&Mid(filepath,InStrRev(filepath,"\")+1)
ec_Class.Message = ec_Class.Message&"文件上傳成功<br>"
upFile=1
Else
ec_Class.Founderr = True
ec_Class.Message = ec_Class.Message&"上傳"&Mid(filepath,InStrRev(filepath,"\")+1)&"文件時失敗<br>"
upFile=0
End IF
End If
End Function
Function GetFileName(filepath)
If filepath <> "" Then
GetFileName = "Info/"&mid(filepath,InStrRev(filepath, "\")+1)
Else
GetFileName = ""
End If
End function
Function getForm()
UpUser = trim(Request.Form("upuser"))
JzName = trim(Request.Form("jzname"))
CsName = trim(Request.Form("csname"))
Path = trim(Request.Form("path"))
Remark = trim(Request.Form("remark"))
If UpUser = "" Then
ec_Class.Founderr = True
ec_Class.Message = ec_Class.Message&"工程師名不能為空<br>"
End If
If JzName = "" Then
ec_Class.Founderr = True
ec_Class.Message = ec_Class.Message&"機種名不能為空<br>"
End If
If CsName = "" Then
ec_Class.Founderr = True
ec_Class.Message = ec_Class.Message&"修改程式名不能為空<br>"
End If
If Path = "" Then
ec_Class.Founderr = True
ec_Class.Message = ec_Class.Message&"上傳路徑不能為空<br>"
End If
If Remark = "" Then
ec_Class.Founderr = True
ec_Class.Message = ec_Class.Message&"修改原因不能為空<br>"
End If
If ec_Class.Founderr = True Then
getForm = 0
Else
getForm = 1
End If
End Function
%>
<SCRIPT language="vbscript">
<!--
Sub checkFile()
filetype = Mid(document.form1.path.value,InStrRev(document.form1.path.value,".")+1)
If UCase(filetype) = "EXE" or UCase(filetype) = "RAR" or UCase(filepath) = "COM" Then
window.alert("文件類型符合要求")
Else
window.alert("你選擇的文件類型為"&filetype&",請選擇類型為(EXE,RAR,COM)!")
window.location = "mbbk.asp"
End If
End Sub//--></SCRIPT>
<body>
<table id="table1" width="80%" align="center">
<tr><td valign="top" height="38">
<table class="style8" id="table2" width="100%" border="0">
<tr>
<td width="70">文件上傳</td>
<td align="right"></td></tr>
</table></td></tr>
<tr><td>
<hr color="#666666" size="1">
<form action="mbbk.asp?action=1 "id="form1" name="form1" method="post">
<table width="500" border="1" align="center" bgcolor="#cccc99">
<tr><td width="250">
<font face="新細明體">工程師:</font></td>
<td><input id="text1" type="text" name="upuser"></td></tr>
<tr><td>
<font face="新細明體">機種名:</font></td>
<td><input id="text2" type="text" name="jzname"></td></tr>
<tr><td>
<font face="新細明體">修改程式名:</font></td>
<td><input id="text3" type="text" name="csname"></td></tr>
<tr><td>
<font face="新細明體">文件路徑:</font></td>
<td><input id="text4" type="file" name="path" onchange="checkFile()"></font></td></tr>
<tr><td>
<font face="新細明體">修改原因:</font></td>
<td><font face="新細明體">
<textarea id="textarea1" name="remark" rows="7" cols="23">
</textarea></font></td></tr>
<tr><td colspan="2" align="center">
<input id="submit1" type="submit" value="提交" class="style1">
<input id="reset1" type="reset" value="重填" class="style1">
</td></tr>
</table></form></td></tr></table>
<hr width="80%" color="#666666" size="1">
</body>
</html>
以上是我的上傳程式,我想控制上傳的類型,但是卻上傳不了檔案了,不過數據可以寫在數據庫哪裡,請問是什麼問題。。