Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2002
    Posts
    6

    Red face Unanswered: 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

  2. #2
    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

  3. #3
    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?

  4. #4
    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

  5. #5
    Join Date
    Nov 2002
    Posts
    13

    link...

    yes thats what I mean...Using BFILE

  6. #6
    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

  7. #7
    Join Date
    Nov 2002
    Posts
    13

    Bfile description & usage

    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

  8. #8
    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

  9. #9
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •