asp做的网站,图片可以上传到服务器啦,但是在前台/后台不能显示
<!-- #include file="../Comm/upload_inc.asp" -->
<%
Sub ShowMsg(MsgStr , FileName)
Response.Write("<script>alert('"& MsgStr &"');")
If FileName = "" Then
Response.Write("history.back();")
ElseIf FileName = "Cls" Then
Response.Write("window.close();")
Else
Response.Write("location.href='"& FileName &"';")
End If
Response.Write("</script>")
Response.End()
End Sub
Dim EmpPic
Dim MyRequest,MyFile,MyFileName,MyFileExt,UpFileType,UpFileName
Set MyRequest = New upload_5xsoft
UpFileType = "jpg|GIF|JPG|jpeg|gif|swf"
AutoFileName = Year(Now) & "_" & Month(Now) & "_" & Day(Now) & "_" & Hour(Now) & "_" & Minute(Now) & "_" & Second(Now)
Set MyFile = MyRequest.File("File_Pic")
MyFileName = Split(MyFile.FileName,".")
MyFileExt = MyFileName(Ubound(MyFileName))
If InStr(UpFileType , MyFileExt) <= 0 Then
ShowMsg "上传的文件的格式不正确" , ""
End If
If MyFile.FileSize < 0 Then
ShowMsg "请选择要上传的文件" , ""
End If
If MyFile.FileSize > 102400 Then
ShowMsg "只能上传大小在100K以内的文件:"& MyFile.FileSize , ""
End If
UpFileName = "Com_Pic/" & AutoFileName & "." & MyFileExt
MyFile.saveas Server.mappath("../" & UpFileName)
Set MyFile = Nothing
Set MyRequest = Nothing
%>
<script language="javascript">
var uppic = "<%=UpFileName%>"
alert("文件上传成功");
opener.PerForm.Pic.value = uppic;
window.close();
</script>
大家看看有什么问题吗?
------解决方案--------------------("../" & UpFileName)
这个是上传的目录,你看下有没有错,
再看下有没有写入数据库中。
------解决方案--------------------一般都是目录问题。对HTML来说,只要目录正确,图片就会出来。