Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2008
    Posts
    2

    Question Unanswered: Storing/updating images using db

    Hello everybody,

    I'm new to this forum, and pretty new to databases. I use php MySQL and Dreamweaver. I have this problem: I need to create an efficient way to upload/update images in a website, like this:

    http://www.centralmadeirense.com.ve/viveres.html

    Until now the little icons, product info, prices, etc, are updated by hand!, one by one. I've been asked to create a form where the administrator could upload the icons, product info, etc. more efficiently and make them appear in the proper place (e.g. using a table like the example above). I'm sure this can be achieved using a dynamic site.

    I know one can store all this info into a db, including the pics. But after reading some tutorials, I find them too hard (the storing pics directly in the db part). Is there a way to just store the pics in a folder of my server, and then use the db to manipulate this information? I don't really need to store the actual images into the db, just a link to them.

    Let's be more specific. I know how to create a recordset and bind the name, price, and description of the product into an php document. I know even how to create a form to do all this automatically. But I don't know how to bind the images located in a folder of my server and "paste" them into the proper place into the php document.


    Any help would be appreciated

    Eduardo

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    store the path to the image in the db and extract that to create the page along aith the other data. how you would do that in Dreamweaver is a mystery to me.. I tend to ue it only for static pages so Im not up to speed on or even if you could within Dreamweaver.

    a few things to bear in mind with storing the path and NOT the image
    1) you need to cater for the situation where the image is not found.. in my books nothing looks tackier on a website than an image not found icon... better to replace with an image not available or no picture at all
    2) you don't have any control over the images, so the images could be edited or deleted or replaced.. that is a problem in as much a malicious attacker could replace your imnage with one of theirs. this can be got round
    by carefull control of who has access to the image area of your filesystem.

    there are advantages
    you can link to pictures outside your site
    images may get cached at the ISP level, meaning lessload on your server
    your db doesn't bloat with information such as images, leading to reduced db size, backup times etc...

    there are libraries such as the GD library in PHP which help with image manipulation
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Oct 2008
    Posts
    2
    Hey man, thanks!

    So, is it as simple as that? Do I use an absolute path like http://www.mysite.com/images/image.gif?
    Then how do I place it in a particular spot of my php doc?, for exaple, a table cell or a div.

    Eduardo

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by edoplaza
    Hey man, thanks!

    So, is it as simple as that? Do I use an absolute path like http://www.mysite.com/images/image.gif?
    Then how do I place it in a particular spot of my php doc?, for exaple, a table cell or a div.

    Eduardo
    thats the problem I foresee.. how you instruct Dreamweaver to insert the PHP varaible


    <img src="http://www.mysite.com/images/image.gif" alt="Angry" />
    or
    <img src="http://www.mysite.com/images/image.gif" alt="text description of your image" />

    have a look a w3schools bit on the img tag
    ideally you should alwasy put an ALT paraemter, and its reccomended that you also specify the image height & width

    you can escape the double quote " in PHP by using \"m, the \ acts as an escape character
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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