Automatically inserting image name in database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lmeeson
    New Member
    • Oct 2008
    • 4

    Automatically inserting image name in database

    hi guys,
    I am totally new to coding so please bare with me.
    I have a file upload field in a form on a PHP page for users to upload pictures, i also have the following fields in my MySQL database

    "image_fold er" - this contains a default value of the image folder in my root folder

    "image_path " - this automatically combines the image_ folder with the image_name to generate the path to the users image

    "image_name " - i want this field to contain the name of the users image

    Does anyone know how i would be able to "grab" the file name and automatically inserts it in the image _name field when the file is uploaded.

    Cheers for any advice
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Hi,

    That's pretty basic, you should find tutorials on that all over the Internet....
    You could start here

    What you should really look into is how you store images in the MySQL database, that would be the "correct" way to display images stored (well not really stored in your case) in a DB...

    /MK

    Comment

    • lmeeson
      New Member
      • Oct 2008
      • 4

      #3
      Originally posted by MarkoKlacar
      Hi,


      What you should really look into is how you store images in the MySQL database, that would be the "correct" way to display images stored (well not really stored in your case) in a DB...

      /MK
      I briefly looked into storing the images on MySQL but the DB would be too big so the only way to do it would be storing the path.

      Thanks for the link, i am trying it out.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        You can get the image name by

        Code:
        $_FILES['uploaded']['name']
        You would have to adapt 'uploaded' to be the name of the file input.

        Comment

        Working...