asp代码文件保存指定文件夹下

asp代码文件保存指定文件夹下,第1张

oFile.SaveToFile FSPath&FileName ''保存文件液禅

修改宽埋悔为慎正

oFile.SaveToFile FSPath&"1/"&FileName ''保存文件

给你段代码,两个文件,你上面的要求都能达到:

《upload_file.asp》此页面作为d出窗口,代码如下:

<!--#include file="UploadClass.asp"-->

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">

<title>文件上传</title>

<link href="images/css.css" rel="stylesheet" type="text/css">

<body bgcolor="#FFFFFF" leftmargin="5" topmargin="20">

<%

Dim Admin_Flag,action

Dim File_ext,UploadSize,Uploadpath

Dim Filepath,Filename,Randnum

Dim Fileext_a,Fileext,UpMode

formname=Request.QueryString("formname")'父页面form表单名字

textname=Request.QueryString("textname")'父页面form内存放图片上传后路径的文本框名字

if textname="AdsFilePath" then '根据文本框名字确定文件保存的路径

UploadPath="adpic/"

elseif textname="WebLogo" then

UploadPath="磨悉WebLogoFile/"

elseif textname="ShopPic" then

UploadPath="Shop_Pic/"

elseif textname="Smaillpic" then

UploadPath="Smaill_pic/"

elseif textname="Bannapic" then

UploadPath="Banna_pic/"

end if

UploadSize=1000

File_ext="jpg,gif,swf"

Select Case Request.QueryString("action")

Case "upload"

Call Main()

Call UpLoad()

Case Else

Call Main()

End Select

Sub Main()

%>

<Form name="myform" method="post" action="?action=upload&formname=<%=formname%>&textname=<%=textname%>" enctype="multipart/Form-data" >

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">

<tr>

<th align="center" class="table_titl">文件上传</th>

</tr>

<tr>

<td height="30" align="center" class="wz" ID="strMsg">允许上传的文件类型:<%=file_ext%></td>

</tr>

<tr>

<td height="30" align="center" class="wz">文件上传大小限制:<%=UploadSize%>K </td>

</tr>

<tr>

<td height="30" align="center" class="wz">请选择上传文件:

<input type="file" name="file1" size=20 class=text>

<input type="hidden" name="filename">

</td>

</tr>

<tr>

<td height="30" align="center" class="wz">隐敬

<input type="submit" name="Submit" value="上传" onClick="filename.value=file1.value" class=button>

</td>

</tr>

</table>

</Form>灶游慎

</body>

</html>

<%

End Sub

Sub UpLoad()

soft_upload()

End Sub

Sub Soft_Upload()

Dim upload,file,uploadsuc,splitFile

Dim upName

set upload=new upfile_class

upload.GetData (-1)

filePath=UploadPath

If right(filePath,1)<>"/" Then filePath=filePath&"/"

For Each upName In upload.file

Set file=upload.file(upName)

If file.filesize<1 Then

Response.Write "<script language=javascript>strMsg.innerHTML='请先选择你要上传的文件'</script>"

Response.end

End If

fileExt=LCase(file.FileExt)

uploadsuc=False

splitFile=Split(File_ext,",")

For i=0 to UBound(splitFile)

If fileEXT=Trim(LCase(splitFile(i))) Then

uploadsuc=True

Exit For

Else

uploadsuc=False

End If

Next

If uploadsuc=False Then

Response.Write "<script language=javascript>strMsg.innerHTML='文件格式不正确'</script>"

Response.end

End If

If file.FileSize>UploadSize*1024 Then

Response.Write "<script language=javascript>strMsg.innerHTML='文件大小超过了限制'</script>"

Response.end

End If

Randomize

filename=filePath&"Love_"&Year(Now)&Month(Now)&Day(Now)&hour(Now)&minute(Now)&second(Now)&randNum&"."&fileExt

file.SaveToFile Server.mappath("../"&FileName) ''保存文件

Check_picwords("../"&FileName) '检查上传文件是否存在违法代码

Response.Write "<script>"

Response.Write "opener."&formname&"."&textname&".value='"&filename&"'"

Response.Write "window.close()"

Response.Write "</script>"

Next

Set file=Nothing

Set upload=Nothing

End Sub

%>

等下补充


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12322520.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存