|
本地测试上传正常,网站图片远程上传,提示上传成功但是没有图片(远程相应目录也没有图片,但上传过程中有目录形成),权限已经改过了故障依旧,请高手指教
<!--#Include File="../../Include/HH_Conn.Asp"-->
<!--#Include File="photoup.inc" -->
<!--#Include File="../../Include/HH_Main.Asp"-->
<html>
<head>
<title>文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
Dim Upload,File,FormName,FormPath,iCount,Filename,FileExt,Fs,SQL,Username,Photochk,Photo,Tupian,znum,Perid,MyPath
Dim P_JiBie,Pic_N,Pic_Yn,P_Name
'检查会员级别
Set Rs=Conn.execute("Select P_JiBie From HH_User Where P_UserId='"&session("P_UserId")&"'")
Select Case Rs("P_JiBie")
Case 0
Pic_N=TT_Pic1
case 1
Pic_N=TT_Pic2
case 2
Pic_N=TT_Pic3
End Select
Call RsClose()
'判断结束,开始判断会员是否已经发满照片
Set Rs=Conn.execute("Select Count(*) As P_N From HH_User_Pic Where P_UserId='"&session("P_UserId")&"'")
If Not Rs.eof Then
IF Rs("P_N")>Pic_N Then
response.write "<script>alert('您已经上传了范围数量内的照片,如果您想上传更多的照片请联系客服!点击返回...');location.href='1_2.Asp';</script>"
response.End()
End If
End If
Call RsClose()
MyPath="../../Pic_Custom/"&session("P_UserId")
'If AutoCreateFolder(server.MapPath(MyPath)) Then
' Response.Write "创建文件夹成功"
'Else
' Response.Write "创建文件夹失败"
'End If
'创建文件夹
AutoCreateFolder(server.MapPath(MyPath))
set upload=new upload_5xSoft ''建立上传对象
formPath=upload.form("filepath")
P_Name =upload.form("P_Name")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
iCount=0
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.filesize<10 then
response.write "<script >alert('请先选择你要上传的图片!重新上传...');history.back(-1);</script>"
response.end
end if
if file.filesize>200000 then
response.write "<script >alert('图片大小超过了限制!最大200k,重新上传...');history.back(-1);</script>"
response.end
end if
fileExt=lcase(right(file.filename,4))
if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".jpeg" then
response.write "<script >alert('文件格式不对!重新上传...');history.back(-1);</script>"
response.end
end if
Randomize timer
zNum = cstr(cint(8999*Rnd+1000))
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&znum&fileExt
if TrueStr(filename)=false then
response.write "<script >alert('文件格式不对...');history.back(-1);</script>"
response.end
end if
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(filename) ''保存文件
' response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 成功!<br>"
iCount=iCount+1
end if
tupian=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&znum&fileExt
set file=nothing
next
set upload=nothing ''删除此对象
'插入图片 HH_User_Pic
P_Name=Replace_Text(Request.Form("P_Name"))
If P_Name="请输入你照片的描述 10 字以内" Then
P_Name="我的照片"
End If
SQL = "Insert Into [HH_User_Pic](P_UserId,P_Name,P_PicUrl,P_AddDate) Values ('"&session("P_UserId")&"','"&P_Name&"','"&tupian&"','"&now()&"')"
Conn.Execute(SQL)
Call ConnClose()
response.write "<script>alert('图片上传成功!点击返回...');location.href='1_2.Asp';</script>"
Function AutoCreateFolder(strPath) ' As Boolean
On Error Resume Next
Dim astrPath, ulngPath, i, strTmpPath
Dim objFSO
If InStr(strPath, "\") <=0 Or InStr(strPath, ":") <= 0 Then
AutoCreateFolder = False
Exit Function
End If
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strPath) Then
AutoCreateFolder = True
Exit Function
End If
astrPath = Split(strPath, "\")
ulngPath = UBound(astrPath)
strTmpPath = ""
For i = 0 To ulngPath
strTmpPath = strTmpPath & astrPath(i) & "\"
If Not objFSO.FolderExists(strTmpPath) Then
' 创建
objFSO.CreateFolder(strTmpPath)
End If
Next
Set objFSO = Nothing
If Err = 0 Then
AutoCreateFolder = True
Else
AutoCreateFolder = False
End If
End Function
function TrueStr(fileTrue)
str_len=len(fileTrue)
pos=Instr(fileTrue,chr(0))
if pos=0 or pos=str_len then
TrueStr=true
else
TrueStr=false
end if
end function
%>
</body>
</html>
|
|