Say in ASP + Access files in image format files

xiaoxiao2021-03-06  40

Designed a product web page, the background is Access

, Field name ID, Model, Photo, Price

I want to ask the master, how to store the image format file in Access, what is the field type?

How to display image files in the database in the web page

<% = WebName%> </ Title></p> <p><meta http-equiv = "content-type" content = "text / html; charSet = GB2312"></p> <p><link rel = "stylesheet" href = "main.css" type = "text / css"></p> <p><style type = "text / css"></p> <p><! -</p> <p>.tx1 {height: 20px; width: 30px; font-size: 9pt; border: 1px solid; border-color: black Black</p> <p># 000000; Color: # 0000FF}</p> <p>-></p> <p></ style></p> <p><script language = "javascript"></p> <p><! -</p> <p>VAR BGC_ON = New Array ("# ​​74d738", "# ff9c17", "# 3278ab", "# 486177", "# 078c00", "# 007eca")</p> <p>VAR BGC_OFF = New Array ("# ​​4CAD12", "FFB859", "5FD0", "577590", "08A700", "009FFF")</p> <p>Function Turnon (Obj1, ID) {</p> <p>Obj1.style.background = bgc_on [id];</p> <p>}</p> <p>Function Turnoff (Obj1, ID) {</p> <p>Obj1.style.background = BGC_OFF [ID];</p> <p>}</p> <p>// -></p> <p></ script></p> <p><Script language = javaScript></p> <p>Function check_input ()</p> <p>{</p> <p>IF (frm.pic.value == "")</p> <p>{Alert ("Please select the picture you want to upload");</p> <p>Return False;</p> <p>}</p> <p>IF (frm.type.value == ")</p> <p>{Alert ("Please select the image type";</p> <p>Return False;</p> <p>}</p> <p>IF (frm.thettlext.value == "")</p> <p>{alert ("Please enter a photo description");</p> <p>Return False;</p> <p>}</p> <p>Return True;</p> <p>}</p> <p></ Script></p> <p></ hEAD></p> <p><body bgcolor = "# 555555" Text = "# 000000" Leftmargin = "0" TopMargin = "0"></p> <p><table width = 755 cellpadding = 0 cellspacing = 0 border = 0 bgcolor = # ffffff align = "center"> <tr></p> <p><TD Height = 100> <img src = "img / Top.gif" align = "top"></p> <p></ TABLE></p> <p><! - # include file = "inc / mulu.asp" -></p> <p><table width = 755 cellpadding = 0 cellspacing = 0 border = 0 bgcolor = # ffffff align = "center" bordercolor = # 000000></p> <p><tr></p> <p><TD Height = 400 width = 180 bgcolor = # D1E9D5 style = "Border-Right: 1px # 0e801e solid"></p> <p><Table Width = 100% Height = 100% Cellpadding = 0 Cellspacing = 0 border = 0 align = "center" bordercolor = # 000000></p> <p><tr> <td height = 30 align = "center" class = l15> <font color = # e96d0> Welcome: <% = username%> management center </ font></p> <p><tr> <td height = 23 align = "center" class = l15 bgcolor = # 4cad12 style = "border-top: 0px # 0e801e solid; border-bottom: 1px # 0e801e solid;"> <font color = # c2f009 class = YINYING> Management Center </ font></p> <p><tr> <TD Height = 20 Class = L13></p> <p><! - # include file = "inc / centermulu.asp" -></p> <p><TR> <TD Height = 5></p> <p><TR> <TD></p> <p></ TABLE></p> <p><TD></p> <p><%</p> <p>SET RS = Server.createObject ("AdoDb.Recordset")</p> <p>SQL = "SELECT * from photo where author = '" & username & "'"</p> <p>RS.Open SQL, CONN, 1, 1</p> <p>%></p> <p><Table cellpadding = 0 cellspacing = 0 border = 0 width = 100% height = 100%></p> <p><TR> <TD Height = 3></p> <p><TR> <TD Height = 3 BGCOLOR = # fffffffFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBGROUND = IMG / BJ3.GIF></p> <p><TR> <TD Height = 20 Valign = "Bottom" BGColor = # eeeeee> Current position: 98243 class - management center - Add News <Tr> <TD Height = 3 BGColor = # eeeeee style = "Border-bottom: 1px # CCCCCC SOLID "> <p style =" font-size: 1pt "></p> <p><tr> <td height = 20 valign = "bottom"> <font color = green> <% = username%>: You upload <font color = red> <% = rs.recordcount%> </ font> Zhang Photo </ font> <a href="adminphoto.asp"> <font color = red> <u> More uploaded previously uploaded photos </ u> </ font> </A></p> <p><TR> <TD BGCOLOR = # ffffff value = top></p> <p><Table cellpadding = 0 cellspacing = 0 border = 0 width = 95% Height = 100% align = "center"></p> <p><form action = addphoto.asp method = post name = fm onsubmit = "Return Check_input ()" ENCTYPE = "Multipart / Form-Data"></p> <p><TR> <TD Height = 20 COLSPAN = 2></p> <p><TR> <TD Height = 25 Width = 15% Align = "Right" Class = L13> Select photo: <TD> <input name = "type =" class = "tx1" style = "width: 300 "> <font color = red> refuses porn, photo map, etc. </ font></p> <p><TR> <TD Height = 25 Width = 20% Align = "Right" Class = L13> Photo Category: <TD> <Select Name = "Type"></p> <p><option selected value = ""> Select type </ option></p> <p><option value = "class photo"> Class photo </ option></p> <p><Option value = "Personal Photo"> Personal Photo </ Option></p> <p><option value = "师 photos"> 师 photo </ option></p> <p><option value = "Valentine photos"> Valentine's photo </ option></p> <p><Option value = "Friends Photos"> Friends Photos </ Option> <option value = "Other Photos"> Other photos </ option></p> <p></ select></p> <p><Tr> <TD Height = 25 Width = 20% Align = "Right" Class = L13> Photo Description: <TD> <textarea name = "THETEXT" cols = "46" rows = "7" style = "border: 1px Double RGB (88, 88, 88); font: 9pt "></p> <p></ textarea> <font color = red> Up to 20 characters </ font></p> <p><TR> <TD Height = 5 COLSPAN = 2></p> <p><TR> <TD Height = 25 COLSPAN = 2 Align = "Center"></p> <p><Input Type = "Submit" Name = "Submit" Value = "提" style = "border: 1px double rgb (88, 88, 88); font: 9pt"></p> <p><input type = "reset" name = "reset" value = "rewrites" style = "border: 1px double RGB (88, 88, 88); font: 9pt"></p> <p><Tr> <TD COLSPAN = 2></p> <p></ tr> </ form></p> <p></ TABLE></p> <p></ TABLE></p> <p></ TABLE></p> <p><! - # include file = "inc / footer.asp" -></p> <p></ body></p> <p></ html></p> <p>Fupload.inc</p> <p><Script runat = server language = vbscript></p> <p>'Limiting upload image size</p> <p>DIM UPLOADSIZELIMIT</p> <p>'*************************************************************************************** *********************</p> <p>Function gameupload ()</p> <p>Dim Result</p> <p>Set result = Nothing</p> <p>If Request.servervariables ("Request_Method") = "post" The 'Request Method Must Be "Post"</p> <p>DIM CT, POSB, Boundary, Length, Pose</p> <p>CT = Request.SerVariables ("http_content_type") 'Reads Content-Type Header</p> <p>IF Lcase (Left (CT, 19)) = "Multipart / Form-Data" Then 'Content-Type Header Must Be "Multipart / Form-Data"</p> <p>'This is upload.</p> <p>'Get the boundary and length from content-type header</p> <p>POSB = INSTR (LCase (CT), "Boundary =") 'FINDS Boundary</p> <p>IF POSB> 0 THEN Boundary = MID (CT, POSB 9) 'Separetes Boundary</p> <p>Length = clng ("http_content_length")) 'Get Content-Length Header</p> <p>IF "" & Uploadsizelimit <> "" "" "</p> <p>UPLOADSIZELIMIT = CLNG (Uploadsizelimit)</p> <p>IF Length> Uploadsizelimit Then</p> <p>'on Error ResMe next' Clears the Input Buffer</p> <p>'Response.addheader "Connection", "Close"</p> <p>'on Error Goto 0</p> <p>Request.binaryRead (Length)</p> <p>Err.raise 2, "Getupload", "Upload Size" & FormatNumber (Length, 0) & "B Exceeds Limit of" & FormatNumber (Uploadsizelimit, 0) & "B"</p> <p>EXIT FUNCTION</p> <p>END IF</p> <p>END IF</p> <p>If Length> 0 and boundary <> "" "" Are The Required Informations ABOUT UPLOAD?</p> <p>Boundary = "-" & boundary</p> <p>Dim head, binary</p> <p>Binary = Request.binaryRead (Length) 'Reads Binary Data from Clom Clom Clom Clom Clom Clom</p> <p>'Retrieves the Upload Fields from Binary Data</p> <p>SET Result = SeparateFields (Binary, Boundary)</p> <p>Binary = Empty 'Clear Variables</p> <p>Else</p> <p>Err.raise 10, "Getupload", "Zero Length Request."</p> <p>END IF</p> <p>Else</p> <p>Err.raise 11, "Getupload", "No File Sent."</p> <p>END IF</p> <p>Else</p> <p>Err.raise 1, "Getupload", "Bad Request Method."</p> <p>END IF</p> <p>Set getupload = result</p> <p>END FUNCTION</p> <p>Function Separatefields (binary, boundary)</p> <p>Dim Posopenboundary, Poscloseboundary, Posndofheader, IslastBoundary</p> <p>DIM Fields</p> <p>Boundary = StringTobinary (Boundary)</p> <p>Posopenboundary = INSTRB (Binary, Boundary)</p> <p>PosCloseboundary = INSTRB (Posopenboundary Lenb (Boundary), Binary, Boundary, 0) Set Fields = CreateObject ("scripting.dictionary")</p> <p>Do While (Posopenboundary> 0 and Poscloseboundary> 0 and not islastboundary)</p> <p>'Header and File / Source Field Data</p> <p>Dim HeaderContent, FieldContent</p> <p>'Header Fields</p> <p>DIM Content_Disposition, FormfieldName, SourceFileName, Content_Type</p> <p>'Helping Variables</p> <p>Dim Field, TwoCharsafterendBoundary</p> <p>'Get End of HEADER</p> <p>Posndofheader = INSTRB (Posopenboundary Len (Boundary), Binary, StringTobinary (VBCRLF VBCRLF))</p> <p>'Separates Field HEADER</p> <p>HeaderContent = MIDB (Binary, Posopenboundary Lenb (Boundary) 2, PosopenBoundary - Lenb (Boundary) - 2)</p> <p>'Separates Field Content</p> <p>FieldContent = MIDB (Binary, (Posndofheader 4), Poscloseboundary - (Posndofheader 4) - 2)</p> <p>'Separates Header Fields from Header</p> <p>GetHeadfields BinaryTostring (HeaderContent), Content_Disposition, FormfieldName, SourceFileName, Content_Type</p> <p>'Create ONE Field and Assign Parameters</p> <p>SET FIELD = CREATEUPLOADFIELD ()</p> <p>Field.name = formfieldname</p> <p>Field.contentdisPosition = Content_DisPosition</p> <p>Field.FilePath = SourceFileName</p> <p>FIELD.FILENAME = GetFileName (SourceFileName)</p> <p>FIELD.CONTENTTYPE = Content_Type</p> <p>Field.Value = FieldContent</p> <p>Field.Length = lenb (fieldcontent)</p> <p>Fields.add FormfieldName, Field</p> <p>'Is this Ending Boundary?</p> <p>TwocharsafterendBoundary = binarytostring (MIDB (Binary, Poscloseboundary lenb (boundary), 2))</p> <p>'Binary.mid (PosCloseboundary Len (Boundary), 2) .string</p> <p>IslastBoundary = twocharsafterendboundary = "-"</p> <p>IF not islastboundary the 'this is not ending boundary - go to next form field.posopenboundary = Poscloseboundary</p> <p>PosCloseboundary = INSTRB (Posopenboundary lenb (boundary), binary, boundary</p> <p>END IF</p> <p>Loop</p> <p>Set SeparateFields = Fields</p> <p>END FUNCTION</p> <p>'******************************** UTILITIES ************** *******************</p> <p>Function BinaryToString (STR)</p> <p>STRTO = ""</p> <p>For i = 1 to lenb (STR)</p> <p>IF ASCB (MIDB (STR, I, 1)> 127 THEN</p> <p>STRTO = STRTO & CHR (ASCB (MIDB (STR, I, 1)) * 256 ASCB (MIDB (STR, I 1, 1))))</p> <p>i = i 1</p> <p>Else</p> <p>STRTO = STRTO & CHR (ASCB (MIDB (STR, I, 1)))))</p> <p>END IF</p> <p>NEXT</p> <p>BinaryToString = STRTO</p> <p>END FUNCTION</p> <p>Function StringTobinary (String)</p> <p>DIM I, B</p> <p>For i = 1 to len (string)</p> <p>B = B & ChRB (ASC (MID (String, I, 1))))</p> <p>NEXT</p> <p>StringTobinary = B</p> <p>END FUNCTION</p> <p>'Separates Header Fields from Upload HEADER</p> <p>Function Getheadfields (Byval Head, Content_Disposition, Name, FileName, Content_Type)</p> <p>Content_disposition = LTRIM (Separatefield (Head, "Content-Disposition:", ";")</p> <p>Name = (Separatefield (Head, "Name =", ";")) 'Ltrim</p> <p>If Left (Name, 1) = "" "" "" "" "" "", 2, len (name) - 2)</p> <p>FileName = (Separatefield (Head, "FileName =", ";")) 'Ltrim</p> <p>IF Left (FileName, 1) = "" "" "" "", 2, Len (filename) - 2)</p> <p>Content_type = LTRIM (Separatefield (Head, "Content-Type:", ";"))</p> <p>END FUNCTION</p> <p>'Separets One Filed Between SSTART and SEND</p> <p>Function Separatefield (from, byval sstart, byval send)</p> <p>Dim Posb, Pose, Sfrom</p> <p>sfrom = lcase (from)</p> <p>POSB = INSTR (SFROM, SSTART)</p> <p>IF POSB> 0 ThenPOSB = POSB LEN (SSTART)</p> <p>Pose = INSTR (POSB, SFROM, SEND)</p> <p>IF pose = 0 Then Pose = INSTR (POSB, SFROM, VBCRLF)</p> <p>If Pose = 0 Then Pose = LEN (SFROM) 1</p> <p>SeparateField = MID (from, POSB, POSE - POSB)</p> <p>Else</p> <p>SeparateField = EMPTY</p> <p>END IF</p> <p>END FUNCTION</p> <p>'Separetes File Name from The Full Path Of File</p> <p>Function GetFileName (Fullpath)</p> <p>DIM POS, POSF</p> <p>POSF = 0</p> <p>For POS = LEN (FULLPATH) TO 1 Step -1</p> <p>Select Case Mid (Fullpath, POS, 1)</p> <p>Case "/", "/": POSF = POS 1: POS = 0</p> <p>End SELECT</p> <p>NEXT</p> <p>IF POSF = 0 THEN POSF = 1</p> <p>GetFileName = MID (Fullpath, POSF)</p> <p>END FUNCTION</p> <p></ Script></p> <p><Script runat = server language = jscript></p> <p>// The function creates field Object.</p> <p>Function createuploadfield () {return new uf_init ()}</p> <p>Function uf_init () {</p> <p>this.name = NULL</p> <p>this.contentdisPosition = NULL</p> <p>this.FileName = NULL</p> <p>this.filepath = NULL</p> <p>this.contentType = NULL</p> <p>THIS.VALUE = NULL</p> <p>this.Length = NULL</p> <p>}</p> <p></ Script></p> <p>Addphoto.asp</p> <p><! - # include file = "conn.asp" -></p> <p><! - # include file = "inc / domin.asp" -></p> <p><! - # include file = "fupload.inc" -></p> <p><%</p> <p>If Request.servervariables ("Request_Method") = "post" then</p> <p>DIM Fields</p> <p>UPLOADSIZELIMIT = 100000</p> <p>Set Fields = getupload ()</p> <p>DIM Field</p> <p>For Each Field in Fields.Items</p> <p>Select Case Field.name</p> <p>Case "thetext" sss = binarytostring (Field.Value)</p> <p>Case "Type" fff = binarytostring (field.value)</p> <p>Case "Submit" Submit = binarytostring (field.value)</p> <p>Case "PIC"</p> <p>FILENAME = Field.FileName</p> <p>FILECONTENTTYPE = Field.ContentType</p> <p>FileValue = Field.ValueEnd SELECT</p> <p>NEXT</p> <p>'---------------</p> <p>IF filename <> "" and filecontettype <> "image / gif" and</p> <p>FileContentType <> "image / pjpeg" THEN</p> <p>%></p> <p><center></p> <p><br> <br></p> <p><font color = red size = 3> The uploaded photo should be a GIF or JPG file! </ Font> <br> <br></p> <p><Input Type = "Button" Value = "Reset" οnclick = "history.go (-1); Return</p> <p>True; "></p> <p></ center></p> <p><%</p> <p>Else</p> <p>'--------------</p> <p>'Start input</p> <p>'-----------</p> <p>Response.write SSS</p> <p>Response.write "<br>"</p> <p>Response.write fff</p> <p>SET RS = Server.createObject ("AdoDb.Recordset")</p> <p>SQL = "SELECT * from Tb Where Theid is Null"</p> <p>RS.Open SQL, CONN, 3, 3</p> <p>rs.addnew</p> <p>RS ("Author) = UserName</p> <p>RS ("ThetExt") = SSS</p> <p>RS ("Types") = fff</p> <p>RS ("HITS") = 1</p> <p>RS ("posttime") = now ()</p> <p>RS ("photo"). Appendchunk FileValue</p> <p>Rs.Update</p> <p>Rs.close</p> <p>%></p> <p><br> <br></p> <p><center> <font color = red</p> <p>Size = 3> Enter personal basic files successfully! </ Font> <br> <br> <form method = "post"</p> <p>Action = "Personinf.asp"> <input type = "submit" value = "Back"> </ form></p> <p></ center></p> <p><%</p> <p>END IF</p> <p>END IF</p> <p>%></p> <p>Showpic.asp</p> <p><! - # include file = "conn.asp" -></p> <p><%</p> <p>ID = Request ("id")</p> <p>SET RS = Server.createObject ("AdoDb.Recordset")</p> <p>SQL = "SELECT * from Tb Where theid =" & id</p> <p>RS.Open SQL, CONN, 1, 3</p> <p>Response.contentType = "image / gif"</p> <p>Response.binarywrite RS ("photo")</p> <p>%></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-77289.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="77289" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.034</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'oIQ8v0AZTjy32VlmihXKUGbGWusOusKBdwL7DlDIKQeMT3Gejsk0TmSQ_2B8Qv7qKC0hSEK_2Bw2k_2FqtAnpcwNR3gA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>