| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2059 人关注过本帖
标题:[求助]梁无惧无组件上传 图片保存问题
只看楼主 加入收藏
潍猊
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-1-2
收藏
 问题点数:0 回复次数:9 
[求助]梁无惧无组件上传 图片保存问题

大家帮忙看看这个功能能不能实现


采用梁无惧无组件上传类使用中,原来文件图片都上传到uploadimg中,在这里想根据每个用户上传图片时,检测有无该用户文件夹,如没有则自动建立,以后所有的该用户图片都上传到相应用户的文件夹中,数据库中用户名表项为username,请问这个功能如何能实现呢?
请教高手帮忙

搜索更多相关主题的帖子: 组件 保存 
2007-01-22 21:44
lailaili
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2006-11-29
收藏
得分:0 
顶一下!
2007-01-23 12:44
cyc308
Rank: 1
等 级:新手上路
帖 子:83
专家分:0
注 册:2005-5-26
收藏
得分:0 
看看fso资料非常多
2007-01-23 13:10
潍猊
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-1-2
收藏
得分:0 
谁能 帮忙解决下啊,代码怎么写啊?  那些一下子看不来,
2007-01-23 18:55
潍猊
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-1-2
收藏
得分:0 
在顶一下 希望在哪里啊?!
2007-02-04 16:46
潍猊
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-1-2
收藏
得分:0 
onClick="window.open('upload_flash.asp?formname=myform&editname=pic3&uppath=uploadimg&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">



uppath=uploadimg 这个路径想改成uploadimg\"用户"
请教怎么改啊
2007-02-04 20:47
潍猊
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-1-2
收藏
得分:0 
uppath=uppath&"uploadimg\"&session("username")&"/"
可以实现该功能,但会传到表单框时却变成了uploadimg用户/中间少了/不知道怎么回事?
2007-02-04 21:33
潍猊
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-1-2
收藏
得分:0 
<%

'文件属性:例如上传文件为c:\myfile\doc.txt
'FileName 文件名 字符串 "doc.txt"
'FileSize 文件大小 数值 1210
'FileType 文件类型 字符串 "text/plain"
'FileExt 文件扩展名 字符串 "txt"
'FilePath 文件原路径 字符串 "c:\myfile"
'使用时注意事项:
'由于Scripting.Dictionary区分大小写,所以在网页及ASP页的项目名都要相同的大小
'写,如果人习惯用大写或小写,为了防止出错的话,可以把
'sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'改为
'(小写者)sFormName = LCase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
'(大写者)sFormName = UCase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
'**********************************************************************
'----------------------------------------------------------------------
dim oUpFileStream

Class upload_file

dim Form,File,Version

Private Sub Class_Initialize
'定义变量
dim RequestBinDate,sStart,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
dim iFileSize,sFilePath,sFileType,sFormvalue,sFileName
dim iFindStart,iFindEnd
dim iFormStart,iFormEnd,sFormName
'代码开始
Version="无组件上传类 Version 0.96"
set Form = Server.CreateObject("Scripting.Dictionary")
set File = Server.CreateObject("Scripting.Dictionary")
if Request.TotalBytes < 1 then Exit Sub
set tStream = Server.CreateObject("adodb.stream")
set oUpFileStream = Server.CreateObject("adodb.stream")
oUpFileStream.Type = 1
oUpFileStream.Mode = 3
oUpFileStream.Open
oUpFileStream.Write Request.BinaryRead(Request.TotalBytes)
oUpFileStream.Position=0
RequestBinDate = oUpFileStream.Read
iFormEnd = oUpFileStream.Size
bCrLf = chrB(13) & chrB(10)
'取得每个项目之间的分隔符
sStart = MidB(RequestBinDate,1, InStrB(1,RequestBinDate,bCrLf)-1)
iStart = LenB (sStart)
iFormStart = iStart+2
'分解项目
Do
iInfoEnd = InStrB(iFormStart,RequestBinDate,bCrLf & bCrLf)+3
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iFormStart
oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sInfo = tStream.ReadText
'取得表单项目名称
iFormStart = InStrB(iInfoEnd,RequestBinDate,sStart)-1
iFindStart = InStr(22,sInfo,"name=""",1)+6
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'如果是文件
if InStr (45,sInfo,"filename=""",1) > 0 then
set oFileInfo= new FileInfo
'取得文件属性
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileName = GetFileName(sFileName)
oFileInfo.FilePath = GetFilePath(sFileName)
oFileInfo.FileExt = GetFileExt(sFileName)
iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr(iFindStart,sInfo,vbCr)
oFileInfo.FileType = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileStart = iInfoEnd
oFileInfo.FileSize = iFormStart -iInfoEnd -2
oFileInfo.FormName = sFormName
file.add sFormName,oFileInfo
else
'如果是表单项目
tStream.Close
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iInfoEnd
oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-2
tStream.Position = 0
tStream.Type = 2
tStream.Charset = "gb2312"
sFormvalue = tStream.ReadText
form.Add sFormName,sFormvalue
end if
tStream.Close
iFormStart = iFormStart+iStart+2
'如果到文件尾了就退出
loop until (iFormStart+2) = iFormEnd
RequestBinDate=""
set tStream = nothing
End Sub

Private Sub Class_Terminate
'清除变量及对像
if not Request.TotalBytes<1 then
oUpFileStream.Close
set oUpFileStream =nothing
end if
Form.RemoveAll
File.RemoveAll
set Form=nothing
set File=nothing
End Sub

'取得文件路径
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function

'取得文件名
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function

'取得扩展名
Private function GetFileExt(FullPath)
If FullPath <> "" Then
GetFileExt = mid(FullPath,InStrRev(FullPath, ".")+1)
Else
GetFileExt = ""
End If
End function

End Class

'文件属性类
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileType,FileStart,FileExt
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
FileType = ""
FileExt = ""
End Sub

'保存文件方法
Public function SaveToFile(FullPath)
dim oFileStream,ErrorChar,i
SaveToFile=1
if trim(fullpath)="" or right(fullpath,1)="/" then exit function
set oFileStream=CreateObject("Adodb.Stream")
oFileStream.Type=1
oFileStream.Mode=3
oFileStream.Open
oUpFileStream.position=FileStart
oUpFileStream.copyto oFileStream,FileSize
oFileStream.SaveToFile FullPath,2
oFileStream.Close
set oFileStream=nothing
SaveToFile=0
end function
End Class
%>
2007-02-04 22:54
潍猊
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-1-2
收藏
得分:0 
<%
if session("username")="" then

response.write "<script language='javascript'>" & chr(13)
response.write "alert('注册登陆后才能上传图片^.^');" & Chr(13)
response.write "window.document.location.href='login.asp';"&Chr(13)
response.write "</script>" & Chr(13)
end if








uppath=uppath&"uploadimg\"&session("username")&"/"

'文件上传路径
filelx=request("filelx") '文件上传类型
formName=request("formName") '回传到上页面编辑框所在Form的Name
EditName=request("EditName") '回传到上页面编辑框的Name
%>
<html>
<head>
<title>图片上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
td{font-size:12px}
a{color:#000000;text-decoration: none}
a:hover{text-decoration: underline}
.tx{height:16px;width:30px;border-color:black black #000000;border-top-width:0px;border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 12px; background-color: #eeeeee; color: #0000FF}
.button{font-size:12px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width: 0px; height: 16px; width: 80px; background-color: #eeeeee; cursor: hand}
.tx1{height:20px;width:30px;font-size:12px;border:1px solid;border-color:black black #000000;color: #0000FF}
-->
</style>
<script language="javascript">
<!--
function mysub()
{
esave.style.visibility="visible";
}
-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="upfile_flash.asp" enctype="multipart/form-data" >
<div id="esave" style="position:absolute; top:18px; left:40px; z-index:10; visibility:hidden">
<TABLE WIDTH=340 BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR><td width=20%></td>
<TD bgcolor=#104A7B width="60%">
<TABLE WIDTH=100% height=120 BORDER=0 CELLSPACING=1 CELLPADDING=0>
<TR>
<td bgcolor=#eeeeee align=center><font color=red>正在上传文件,请稍候...</font></td>
</tr>
</table>
</td><td width=20%></td>
</tr></table></div>
<table width="400" border="1" cellspacing="0" cellpadding="3" align="center" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr bgcolor="#CCCCCC">
<td height="22" align="left" valign="middle" bgcolor="#CCCCCC" width="400">&nbsp;照片上传
<input type="hidden" name="filepath" value="<%=uppath%>">
<input type="hidden" name="filelx" value="<%=filelx%>">
<input type="hidden" name="EditName" value="<%=EditName%>">
<input type="hidden" name="FormName" value="<%=formName%>">
<input type="hidden" name="act" value="uploadfile">
</td>
</tr>
<tr align="center" valign="middle">
<td align="left" id="upid" height="80" width="400"> 选择照片:
<input type="file" name="file1" style="width:300'" class="tx1" value=""> </td>
</tr>
<tr align="center" valign="middle" bgcolor="#eeeeee">
<td bgcolor="#eeeeee" height="24" width="400">
<input type="submit" name="Submit" value="· 开始上传 ·" class="button" onclick="javascript:mysub()">
</td>
</tr>
</table>
</form>
</body>
</html>
2007-02-04 23:12
潍猊
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-1-2
收藏
得分:0 
问题自己解决了,不用回了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2007-02-05 14:10
快速回复:[求助]梁无惧无组件上传 图片保存问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018955 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved