he llegado a una meta que me habia propuesto, y es la de poder meter imagenes en una base de datos acces, y traerlas nuevamente para mostrarlas en un datagrid a modo de "galeria de fotos" si se quiere... Se que hay gente que lo hizo primero... pero lo que yo queria era hacerlo facil...
y aqui les va....
primera hoja se llama insert.htm ( esta asi en ingles la interface por que es para una aplicacion en ingles) y sirve para elegir la foto a subir.
Código HTML:
<!-- insert.htm --> <html> <head> <title>Inserts Images into Database</title> <style> body, input { font-family:verdana,arial; font-size:10pt; } </style> </head> <body> <p align="center"> <b>Inserting Binary Data into Database</b><br> <a href="show.asp">To see inserted data click here</a> </p> <table border="0" align="center"> <tr> <form method="POST" enctype="multipart/form-data" action="Insert.asp"> <td>First Name :</td> <td> <input type="text" name="fname" size="40"></td> </tr> <td>Last Name :</td> <td> <input type="text" name="lname" size="40"></td> </tr> <td>Profession :</td> <td> <input type="text" name="profession" size="40"> </td> </tr> <td>File :</td> <td> <input type="file" name="file" size="40"></td> </tr> <td> </td> <td> <input type="submit" value="Submit"></td> </tr> </form> </tr> </table> </body> </html>
Bien ahora la hoja que sigue es la que procesa los datos y pregunta si se desea subir alguna otra imagen...
se llama insert.asp
Código HTML:
<% ' Insert.asp %> <!--#include file="Loader.asp"--> <% Response.Buffer = True ' load object Dim load Set load = new Loader ' calling initialize method load.initialize ' File binary data Dim fileData fileData = load.getFileData("file") ' File name Dim fileName fileName = LCase(load.getFileName("file")) ' File path Dim filePath filePath = load.getFilePath("file") ' File path complete Dim filePathComplete filePathComplete = load.getFilePathComplete("file") ' File size Dim fileSize fileSize = load.getFileSize("file") ' File size translated Dim fileSizeTranslated fileSizeTranslated = load.getFileSizeTranslated("file") ' Content Type Dim contentType contentType = load.getContentType("file") ' No. of Form elements Dim countElements countElements = load.Count ' Value of text input field "fname" Dim fnameInput fnameInput = load.getValue("fname") ' Value of text input field "lname" Dim lnameInput lnameInput = load.getValue("lname") ' Value of text input field "profession" Dim profession profession = load.getValue("profession") ' destroying load object Set load = Nothing %> <html> <head> <title>Inserts Images into Database</title> <style> body, input, td { font-family:verdana,arial; font-size:10pt; } </style> </head> <body> <p align="center"> <b>Inserting Binary Data into Database</b><br> <table width="700" border="1" align="center"> <tr> <td>File Name</td><td><%= fileName %></td> </tr><tr> <td>File Path</td><td><%= filePath %></td> </tr><tr> <td>File Path Complete</td><td><%= filePathComplete %></td> </tr><tr> <td>File Size</td><td><%= fileSize %></td> </tr><tr> <td>File Size Translated</td><td><%= fileSizeTranslated %></td> </tr><tr> <td>Content Type</td><td><%= contentType %></td> </tr><tr> <td>No. of Form Elements</td><td><%= countElements %></td> </tr><tr> <td>First Name</td><td><%= fnameInput %></td> </tr><tr> <td>Last Name</td><td><%= lnameInput %></td> </tr> <tr> <td>Profession</td><td><%= profession %></td> </tr> </table><br><br> <p style="padding-left:220;"> <%= fileName %> data received ...<br> <% ' Checking to make sure if file was uploaded If fileSize > 0 Then ' Connection string Dim connStr connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" connStr = connStr & Server.MapPath("FileDB.mdb") ' Recordset object Dim rs Set rs = Server.CreateObject("ADODB.Recordset") rs.Open "Files", connStr, 2, 2 ' Adding data rs.AddNew rs("File Name") = fileName rs("FileSize") = fileSize rs("FileData").AppendChunk fileData rs("ContentType") = contentType rs("First Name") = fnameInput rs("Last Name") = lnameInput rs("Profession") = profession rs.Update rs.Close Set rs = Nothing Response.Write "<font color=""green"">File was successfully uploaded..." Response.Write "</font>" Else Response.Write "<font color=""brown"">No file was selected for uploading" Response.Write "...</font>" End If If Err.number <> 0 Then Response.Write "<br><font color=""red"">Something went wrong..." Response.Write "</font>" End If %> </p> <br> <table border="0" align="center"> <tr> <form method="POST" enctype="multipart/form-data" action="Insert.asp"> <td>First Name :</td><td> <input type="text" name="fname" size="40" ></td> </tr> <td>Last Name :</td><td> <input type="text" name="lname" size="40" ></td> </tr> <td>Profession :</td><td> <input type="text" name="profession" size="40" ></td> </tr> <td>File :</td><td> <input type="file" name="file" size="40"></td> </tr> <td> </td><td> <input type="submit" value="Submit"></td> </tr> </form> </tr> </table> </body> </html>