| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 572 人关注过本帖
标题:[求助]上传图片和图片显示问题!急~
只看楼主 加入收藏
renqian1320
Rank: 1
等 级:新手上路
帖 子:126
专家分:0
注 册:2005-6-27
收藏
 问题点数:0 回复次数:0 
[求助]上传图片和图片显示问题!急~

<%@ codepage = 936 %>
<% If Session("blog_status") <> "login" Then Response.Redirect "login.asp" %>
<% Session.Timeout = 20 %>
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
%>
<style>
a:link{color:#000000;text-decoration:none;}
a:visited{color:#000000;text-decoration:none;}
a:active{color:#000000;text-decoration:none;}
a:hover{color:#ee3333;text-decoration:none;}

</style>
<!--#include virtual="/admin/db.asp"-->
<!--#include virtual="/admin/aspmkrfn.asp"-->
<% Response.Buffer = True %>
<%
If Request.TotalBytes > 0 Then
rawData = Request.BinaryRead(Request.TotalBytes)
separator = MidB(rawData, 1, InStrB(1, rawData, ChrB(13)) - 1)
lenSeparator = LenB(separator)
Set dict = Server.CreateObject("Scripting.Dictionary")
currentPos = 1
inStrByte = 1
tempValue = ""
While inStrByte > 0
inStrByte = InStrB(currentPos, rawData, separator)
mValue = inStrByte - currentPos
If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)
Set intDict = Server.CreateObject("Scripting.Dictionary")
begPos = 1 + InStrB(1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
nValue = endPos
nameN = MidB(value, begPos, endPos - begPos)
isValid = True
If InStrB(1, value, stringToByte("Content-Type")) > 1 Then
begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
If endPos = 0 Then
endPos = begPos + 1
isValid = False
End If
midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", Trim(byteToString(midValue))
begPos = 14 + InStrB(endPos + 1, value, stringToByte("Content-Type:"))
endPos = InStrB(begPos, value, ChrB(13))
midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentType", Trim(byteToString(midValue))
begPos = endPos + 4
endPos = LenB(value)
nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = Trim(byteToString(MidB(value, nValue + 5)))
End If
If isValid = True Then
If dict.Exists(byteToString(nameN)) Then
Set intDict = dict.Item(byteToString(nameN))
If Right(intDict.Item("Value"), 2) = vbCrLf Then
intDict.Item("Value") = Left(intDict.Item("Value"), Len(intDict.Item("Value"))-2)
End If
intDict.Item("Value") = intDict.Item("Value") & ", " & nameValue
Else
intDict.Add "Value", nameValue
intDict.Add "Name", nameN
dict.Add byteToString(nameN), intDict
End If
End If
End If
currentPos = lenSeparator + inStrByte
Wend

' Get action
a = getValue("a")
EW_Max_File_Size = getValue("EW_Max_File_Size")

' For the BLOB field
fs_x_Image = getFileSize("x_Image")

' Check the file size
If fs_x_Image > 0 And CLng(EW_Max_File_Size) > 0 Then
If fs_x_Image > CLng(EW_Max_File_Size) Then
Response.Write "Max. file size (" & EW_Max_File_Size & " bytes) exceeded."
Response.End
End If
End If
fn_x_Image = getFileName("x_Image")
ct_x_Image = getFileContentType("x_Image")
x_Image = getFileData("x_Image")
w_x_Image = getValue("w_x_Image")
h_x_Image = getValue("h_x_Image")

' for other fields
x_PictureID = getValue("x_PictureID")
x_Subject = getValue("x_Subject")
x_CategoryID = getValue("x_CategoryID")
x_filename = getValue("x_filename")
x_width = getValue("x_width")
x_length = getValue("x_length")
If IsObject(intDict) Then
intDict.RemoveAll
Set intDict = Nothing
End If
dict.RemoveAll
Set dict = Nothing
Else
key = Request.Querystring("key")
If key <> "" Then
a = "C" 'copy record
Else
a = "I" 'display blank record
End If
End If
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
Select Case a
Case "C": ' 拷贝操作
tkey = "" & key & ""
strsql = "SELECT * FROM [Picture] WHERE [PictureID]=" & tkey
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
If rs.Eof Then
Response.Clear
Response.Redirect "Picturelist.asp"
Else
rs.MoveFirst

' Get the field contents
x_PictureID = rs("PictureID")
x_Subject = rs("Subject")
x_Image = rs("Image")
x_CategoryID = rs("CategoryID")
x_filename = rs("filenamePath")
x_width = rs("width")
x_length = rs("length")
End If
rs.Close
Set rs = Nothing
Case "A": '添加操作

' Open record
strsql = "SELECT * FROM [Picture] WHERE 0 = 1"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
rs.AddNew
tmpFld = Trim(x_Subject)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Subject") = tmpFld
tmpFld = x_CategoryID
If Not IsNumeric(tmpFld) Then tmpFld = 0
rs("CategoryID") = CLng(tmpFld)
tmpFld = Trim(ct_x_Image)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("filenamepath") = tmpFld
tmpFld = x_Image
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
If IsNull(tmpFld) Then
rs("Image") = Null
Else
rs("Image").AppendChunk tmpFld
End If
tmpFld = fn_x_Image
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("filenamepath") = tmpFld
tmpFld = w_x_Image
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("width") = tmpFld
tmpFld = h_x_Image
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("length") = tmpFld
rs.Update
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Clear
Response.Redirect "Picturelist.asp"
End Select
%>
<!--#include file="header.asp"-->
<p><span class="aspmaker">&nbsp;&nbsp;&nbsp;&nbsp;写博客 -->> 图片 -->> 添加 </span>
<div class="aspmaker" align="right"><a href="Picturelist.asp">返回</a></div>
</p>
<script language="JavaScript" src="ew.js"></script>
<script language="JavaScript">
<!-- start Javascript
function EW_checkMyForm(EW_this) {
return true;
}
// end JavaScript -->
</script>
<form onSubmit="return EW_checkMyForm(this);" action="Pictureadd.asp" method="post" enctype="multipart/form-data">
<p align="center">
<input type="hidden" name="a" value="A">
<input type="hidden" name="EW_Max_File_Size" value="20000000">
<table class="ewTable">
<tr>
<td class="ewTableHeader">标题&nbsp;</td>
<td class="ewTableAltRow"><input type="text" name="x_Subject" size="30" maxlength="60" value="<%= Server.HTMLEncode(x_Subject&"") %>">&nbsp;</td>
</tr>
<tr>
<td class="ewTableHeader">分类标识&nbsp;</td>
<td class="ewTableAltRow"><%
x_CategoryIDList = "<select name='x_CategoryID'><option value=''>请选择类别</option>"
sqlwrk = "SELECT [CategoryID], [Name] FROM [Category]"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.Eof Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
x_CategoryIDList = x_CategoryIDList & "<option value='" & datawrk(0, rowcntwrk) & "'"
If CStr(datawrk(0, rowcntwrk)&"") = CStr(x_CategoryID&"") Then
x_CategoryIDList = x_CategoryIDList & " selected"
End If
x_CategoryIDList = x_CategoryIDList & ">" & datawrk(1, rowcntwrk) & "</option>"
Next
End If
rswrk.Close
Set rswrk = Nothing
x_CategoryIDList = x_CategoryIDList & "</select>"
Response.Write x_CategoryIDList
%>
&nbsp;</td>
</tr>
<tr>
<td class="ewTableHeader">图片&nbsp;</td>
<td class="ewTableAltRow"><input type="hidden" name="w_x_Image"><input type="hidden" name="h_x_Image"><input type="file" name="x_Image" onChange="EW_getimagesize(this, this.form.w_x_Image, this.form.h_x_Image);">&nbsp;</td>
</tr>
</table>
<p align="center">
<input type="submit" name="Action" value="添加">
</form>
<!--#include file="footer.asp"-->
以上代码是后太控制上传图片到数据中,图片上传上去后,在前台图片显示不出来,
是个XX,在个图片的标题都变了乱码,我表中的主要字段
pictureid
subject (图片标题)
image (图片内容) 类型:ole对象
categoryid (图片类别)
filenamepath(图片路径)
帮我看看,谢谢哦.~

搜索更多相关主题的帖子: Response blog none Session 
2006-07-11 13:47
快速回复:[求助]上传图片和图片显示问题!急~
数据加载中...
 
   



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

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