Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    102
    Thanks
    3
    Thanked 0 Times in 0 Posts

    MYSQL Help displaying Images

    hello guys

    well at the moment i am making a site and what is happening is this there is a form that you fill out and submit to a database. Now with the form there is a thing to upload images, a headline form and a message form. The headline is first hten the image uploader then the message. This is the tricky part. Should i on the page with the form put an image uploader in the form page and make the image upload and reload the page with the img tags which submit to the database (Do Img tags allow you to show images in mysql?) Or does anyone know any better ways i can show the article with the image used. That way the image is still uploading to the server but the link of the image is stored in the database and can be pulled out in [img] tags (if they can be used) A net article or any help is much appreciated!!

    Thanks

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    I'm not sure what you're asking.

    If you're asking whether or not you can store image data in a blob in MySQL and pull it out, the answer is yes, and the method is different based on what server programming language you're using. The basic principle is for a dynamic server page to send a header with the proper image type (like jpeg) and then stream the data from the mysql field.

    If you're asking about whether or not you should display the image immediately after uploading, or something site design question, I don't know.

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    The way I usually see this done is by uploading the image file to a web directory and storing the filename in your database. When you need to display the image you just display an img src with the filename in it:

    <img src="/uploads/images/<? echo $uploadedfilename; ?>">

    As beagle mentioned, you can also use BLOBs and store the images directly in your database. Depending on your webhost, you might not be allowed to store all kinds of data in your database (due to space constraints).
    Last edited by arnyinc; 07-18-2006 at 06:32 PM.

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Posts
    102
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Ok thanks for that

    Now with the code <img src="/uploads/images/<? echo $uploadedfilename; ?>"> And it uploads to a database and say the Story name is Test and the image is testa.jpg will it display right image on say www.yoursite.com/article.php?id=1 would it display the right image?

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Posts
    102
    Thanks
    3
    Thanked 0 Times in 0 Posts
    What if you put an iframe on the page with all the forms and made a form for image url which gave you the link to the image which you put in img tags and put with all other info in the row with the article in the database could you do it that way?


  •  

    Posting Permissions

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