If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > retrive image from database by asp?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-04-02, 11:30
tahereh tahereh is offline
Registered User
 
Join Date: Jul 2002
Posts: 6
Red face retrive image from database by asp?

hi all
i want to retrive image from DataBase with ASP
but i dont know what must i do?
please guide me
Reply With Quote
  #2 (permalink)  
Old 09-06-02, 06:59
JonathanB JonathanB is offline
Registered User
 
Join Date: Feb 2002
Location: North Wales, UK
Posts: 114
I'm assuming that the image is physically stored in a database field with this code...

<%
'database connection code goes here
'assuming data_rs is the recordset containing the actual image

response.ContentType = "application/jpeg"
response.expires = 0
response.binarywrite(data_rs("IMAGEBLOB")
response.end

%>
__________________
J^ - web | email
newsASP Developer
Reply With Quote
  #3 (permalink)  
Old 12-02-02, 04:41
Philby_Walsh Philby_Walsh is offline
Registered User
 
Join Date: Nov 2002
Posts: 13
linked..

how would you go about it if the only a LINK to the image was stored in the databse (using BFILE in ORACLE)...??

Would it be possible to allow the user to search for a string of text & then return a picture (or a number of pictures) based on the results of that search?
Reply With Quote
  #4 (permalink)  
Old 12-02-02, 12:44
JonathanB JonathanB is offline
Registered User
 
Join Date: Feb 2002
Location: North Wales, UK
Posts: 114
By "LINK" I'm assuming you mean the URL to the image on the file system??
__________________
J^ - web | email
newsASP Developer
Reply With Quote
  #5 (permalink)  
Old 12-02-02, 14:04
Philby_Walsh Philby_Walsh is offline
Registered User
 
Join Date: Nov 2002
Posts: 13
link...

yes thats what I mean...Using BFILE
Reply With Quote
  #6 (permalink)  
Old 12-02-02, 15:29
JonathanB JonathanB is offline
Registered User
 
Join Date: Feb 2002
Location: North Wales, UK
Posts: 114
Just been reading up and BFILE appears to be the "binary file" type for Oracle..? I take it then that the whole file is stored in this field in the Oracle db?? If it is then I'd guess you could use a similar method as I have above providing the Oracle ODBC driver allows it.

Providing a search would just be a case of going through any string fields associated with the file itself. I'm afraid I haven't used Oracle very much at all yet.
__________________
J^ - web | email
newsASP Developer
Reply With Quote
  #7 (permalink)  
Old 12-03-02, 06:37
Philby_Walsh Philby_Walsh is offline
Registered User
 
Join Date: Nov 2002
Posts: 13
Bfile description & usage

Quote:
Originally posted by JonathanB
Just been reading up and BFILE appears to be the "binary file" type for Oracle..? I take it then that the whole file is stored in this field in the Oracle db?? If it is then I'd guess you could use a similar method as I have above providing the Oracle ODBC driver allows it.

Providing a search would just be a case of going through any string fields associated with the file itself. I'm afraid I haven't used Oracle very much at all yet.
No, JonathanB, BFILE stores a locator in the record that points to the location of the file on a file system outside of oracle...check out this below..

• BFILE Datatype Download Readme Source
The BFILE datatype enables access to binary file LOBs that are stored in file systems outside the Oracle database. A BFILE column or attribute stores a BFILE locator, which serves as a pointer to a binary file on the server's file system. The locator maintains the directory alias and the filename. This sample application demonstrates accessing of BFILEs using SQLJ. Posted on 05-Sep-2002.


http://otn.oracle.com/sample_code/te...ancedsqlj.html

What i need to do is
  • Allow users to upload the file (To my webspace NOT the oracle DB) but store a BFILE locator in the DB that will point to it
  • Allow users to search for specific files (EG associated with a particular band) and be given back a list of links to specific files which apply to that search
  • They need to be able to follow this link & download/or view (if it is a picture) the file
  • This all has to be done dynamically - if i log-in at 3-00pm and upload a sound file (and finish uploading at 3-10pm), someone who logs in at 3-11pm should be able to search for & download this file...in other words the site should operate independant of any admin work..

Now lads...is this possible? I think it might be but I'm not experienced enough in ASP or ORACLE to be sure...thanks, Phil
Reply With Quote
  #8 (permalink)  
Old 12-03-02, 06:54
JonathanB JonathanB is offline
Registered User
 
Join Date: Feb 2002
Location: North Wales, UK
Posts: 114
Providing you can use this BFILE fields in ASP there shouldn't be a problem. Try outputting the contents of this field to the browser through ASP to see what you can do with it.

What you describe is basically the definition of a dynamic site, it's just a case of doing some testing on Oracle to see how best to go about your task.
__________________
J^ - web | email
newsASP Developer
Reply With Quote
  #9 (permalink)  
Old 12-03-02, 15:36
brandonh6k brandonh6k is offline
Registered User
 
Join Date: Nov 2002
Posts: 11
Just out of curiousity, why are you using a BFILE field to store the info...? Wouldn't it make more sense to use a normal text field and just store a relative URL? That way you don't have to worry about the format of the BFILE field, you can just dump a URL out to the ASP page...

Something like this comes to mind...

Upload.asp -> stores the file, it's location and any other descriptive stuff...

Browse.asp -> reads the database for available files and displays the info...

Download.asp -> gets a link to the file along with size and other info.

So, you would have the upload.asp page store the file in a directory (call it upload for the sake of argument and it's at /upload on the web tree). Once this file is uploaded, you store some tidbits of info in the DB (i.e. file name (test.mp3), file size (250Kb), who uploaded (brandon), when uploaded (12/2/2002 1:30 pm), etc.). Now the browse.asp page will allow you to load all the info in the database that fits some specified criteria (just standard ASP database stuff). And once you find something you like, download.asp generates a page with a hyperlink to the file and anything else you want to display (file size, contributor).

Now if all you're files are always in the same directory, you can just store the file name and build the URL with that info:

Code:
<a href="/upload/<%= objRS("filename") %>"><%= objRS("filename") %></a>
(objRS is an ADO Recordset talking to the database)

If your files are in different directories, it's a little more complicated, but not significantly so...

Sorry for the long winded response, but hopefully it helps...
__________________
- Brandon
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On