SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Database path store.

    Alright, how in the world can I do this:

    uploadforms.php - A form where you simply input a title, choose a file to upload, add a comment for the file, and select a catagory for the file. All of this info is then passed onto upload.php

    upload.php - this takes the info from the forms puts it in a database, I know how to get all the text into the database, but how can i store the file location of the file in the DB (the location of the file on the server)? I cannot seem to get this, and I have been at it for weeks....

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    heres how to handle file uploads
    http://us2.php.net/manual/en/features.file-upload.php

    once you move the file, you will know its name and path.
    just add it to the db.

  3. #3
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, thats my question, how do i store the path in the db all automatically in one go?

    I have this so far, would this work:

    PHP Code:
     $filename $file['tmp_name']
    $path move_uploaded_file($file['tmp_name'], 'images/' $filename);

    $sql "insert into user_art
                      (title, caption, path) values
                    ('
    $name', '$caption', '$path')"
    ??

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the same way you add the other text to a query(the file path is just text too). make a field for it in the database, and add it into the query.
    Last edited by clamcrusher; Mar 31, 2006 at 01:59.

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     $filename $file['tmp_name']
    move_uploaded_file($file['tmp_name'], 'images/' $filename);
    $path 'images/' $filename;

    $sql "insert into user_art
                      (title, caption, path) values
                    ('
    $name', '$caption', '$path')"


Bookmarks

Posting Permissions

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