<!-- #INCLUDE FILE="include/config.asp" -->
<!--#include file="include/upload_config.asp"-->
<!--#include file="include/conn.asp"-->
<script langiage='javascript' src='style/joekoe_config.js'></script>
<script langiage='javascript' src='style/mouse_on_title.js'></script>
<html>
<head>
<title><%response.write web_var(web_config,1)%> - 文件上传</title>
<meta http-equiv=Content-Type content=text/html; charset=gb2312>
<link rel=stylesheet href='images/joekoe.css' type=text/css>
</head>
<body topmargin=0 leftmargin=0 bgcolor=<%response.write web_var(web_color,1)%>>
<table border=0 height='100%'cellspacing=0 cellpadding=0><tr><td height='100%'>
<%
dim formname,upload_path,upload_type,upload_size,uup,web_path
uup="|article|down|forum|gallery|news|other|product|video|website|userface|"
action=trim(request.querystring("action"))
if var_null(login_username)="" or var_null(login_password)="" then
  response.write " "&nologin_info
elseif post_chk()="no" then
  response.write web_var(web_error,1)
else
  web_path=web_var(web_config,2)
  upload_path=web_var(web_upload,1)
  upload_type=web_var(web_upload,5)
  upload_size=web_var(web_upload,3)
  select case action
  case "upfile"
    call upload_chk()
  case else
    call upload_main()
  end select
end if

call close_conn()

sub upload_chk()
  Server.ScriptTimeOut=5000
  dim upload,up_text,up_path,uptemp,uppath,up_name,MyFso,upfile,upcount,upfilename,upfile_name,upfile_name2,upfilesize,upid
  set upload=new upload_classes
  set MyFso=CreateObject("Scripting.FileSystemObject")
  upcount=1
  up_name=trim(upload.form("up_name"))
  up_text=trim(upload.form("up_text"))
  up_path=trim(upload.form("up_path"))
  if int(instr(uup,"|"&up_path&"|"))=0 then up_path="other"
  if len(up_path)<3 then up_path="other"
  uppath=up_path
  if right(upload_path,1)<>"/" then upload_path=upload_path&"/"
  up_path=server.mappath(upload_path&up_path)
  if not MyFso.folderExists(up_path) then
    set up_path=MyFso.CreateFolder(up_path)
  end if
  if right(up_path,1)<>"/" then up_path=up_path&"/"
  'if right(uppath,1)<>"/" then uppath=uppath&"/"

  set upfile=upload.file("file_name1")
  upfilesize=upfile.FileSize
  upload_size=upload_size*1024
  if upfilesize>0 then
    upfilename=upfile.FileName
    if upfilesize>upload_size then
      uptemp="<font class=red_2>上传失败</font>：文件太大！(不能超过"&int(upload_size/1024)&"KB) "&go_back
    else
      upfile_name=Right(upfilename,(len(upfilename)-Instr(upfilename,".")))
      upfile_name=lcase(upfile_name)
      if instr(","&upload_type&",",","&upfile_name&",")>0 then
        upfile_name2=upfile_name
        upfile_name=up_name&"."&upfile_name
        upfile.SaveAs up_path&upfile_name
        uptemp="<font class=red>恭喜你,你的头像上传成功,请设置头像高度和宽度再更新资料!</font>"
        if instr(up_text,"pic")>0 then
          uptemp=uptemp&"<script>parent.document.all."&up_text&".value='"&uppath&"/"&upfile_name&"'</script>"
        else
          uptemp=uptemp&"&nbsp;&nbsp;<script>parent.document.all."&up_text&".value+='"
          select case lcase(upfile_name2)
          case "gif","jpg"
            uptemp=uptemp&upload_path&uppath&"/"&upfile_name
          end select
          uptemp=uptemp&"\n'</script>"
        end if
      else
        uptemp="<font class=red_2>上传失败</font>：文件类型只能为："&replace(upload_type,"|","、")&"等格式) "&go_back
      end if
    end if
  else
    uptemp="<font class=red_2>上传失败</font>：您可能没有选择想要上传的文件！"&go_back
  end if
  set upfile=nothing
  response.write uptemp
  set MyFso=nothing
  set upload=nothing
end sub

sub upload_main()
  dim uppath,upname,uptext
  uppath=trim(request.querystring("uppath"))
  upname=trim(request.querystring("upname"))
  uptext=trim(request.querystring("uptext"))
  if int(instr(uup,"|"&uppath&"|"))=0 then response.write "参数出错！":exit sub
  if len(uppath)<1 or len(uptext)<1 then response.write "参数出错！":exit sub
  if len(upname)<3 then upname=upname&upload_time(now_time)
%>
<table border=0 cellspacing=0 cellpadding=2>
<form name=form1 action='?action=upfile' method=post enctype='multipart/form-data'>
<input type=hidden name=up_path value='<%response.write uppath%>'>
<input type=hidden name=up_name value='<% response.write upname %>'>
<input type=hidden name=up_text value='<% response.write uptext %>'>
<tr>
<td><input type=file name=file_name1 value='' size=16></td>
<td align=center height=30><input type=submit name=submit value='点击上传'> (<=<% response.write upload_size %>KB)</td>
</tr>
</form>
</table>
<% end sub %>
</td></tr></table>
</body>
</html>