i'm able to upload a file into a directory. if i were to store the file into a table how would i retrieve the file back from the table. the file type could be image or .doc or spreadsheet or html. pls. help me in this regard. thanks
How are you doing the upload - i.e. what server side software is receiving the file.
If you're not familiar with this whizz over to persits who have something called ASPUpLoad - there is a demo version you can download, shove on your webserver and try out.
This comes with quite a few working examples - well worth a go.
FWIW I generally try to avoid storing uploaded files in any kind of a table - store them in a sensible dir structure and
manage them that way.
i'm using sql server as the back end. i've downloaded asp upload as instructed by u from microsoft site & am able to upload into a directory over the site. But isn't there any advantage in storing it in a database. anyhow my boss insists on storing it in a database as to avoid manual deletion to overwrite the file. pls. do help me how i can store it in a column name as well as download the image or doc or html file as such.
I had an idea that there was an example in the stuff that comes with ASPUpload, I'll have a look in a bit.
There are two or three disadvantages with placing the data directly into the tables.
1) If you spoil your database, your images will all be lost.
2) The database size may well become huge (GB in some cases)
3) It will take longer to upload and retrieve the information.
The ASP stuff will allow you to do 'pseudo logins' which means the images can be placed somewhere that accidental damage cannot occur.
I'll see if I can find a code sample for what you want though.
On the persits site I found a manual section under the ASPUpload 3.0 heading...
In there I found this code for importing files into an ODBC
compliant database
' Obtain file object
Set File = Upload.Files("THEFILE"
If Not File Is Nothing Then
' Build ODBC connection string
Connect = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(".\aspupload.mdb"
' If you use SQL Server, the connecton string must look as follows:
' Connect = "Driver=SQL Server;Server=MYSERVER;UID=sa;PWD=xxxxxxxxx"
' Save to database
File.ToDatabase Connect, SQL
Response.Write "File saved."
Else
Response.Write "File not selected."
End If
%>
</BODY>
</HTML>
For export...
<%
Set db = Server.CreateObject("ADODB.Connection"
db.Open Connect
SQL = "SELECT * FROM MYIMAGES where id = " & Request("id"
Set rs =db.Execute( SQL )
Response.ContentType = "application/octet-stream"
' let the browser know the file name
Response.AddHeader "Content-Disposition", "attachment;filename=" & Trim(rs("filename")
' let the browser know the file size
Response.AddHeader "Content-Length", rs("filesize"
Response.BinaryWrite rs("image_blob"
%>
I am able to do this with ur sample code. thanks for sending me the sample code as well. i think maintaing a proper dir. structure as suggested by you earlier is a better option.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.