Rename uploaded files to column ID

Discussion in 'MySQL' started by rps111, Aug 23, 2007.

  1. #1
    Hi all.
    I am trying to build a PHP web form that feeds the data in a MySQL database. The data entered is varchar and a file is also uploaded.

    The following columns are present in the database:
    vName (not null)
    vNameID (auto increment)
    vFileName
    vDescription

    I want that the file should be stored in a folder named ./files/ and that the uploaded file should be renamed to vNameID.

    Thanks in advance.
     
    rps111, Aug 23, 2007 IP
  2. tandac

    tandac Active Member

    Messages:
    337
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    There's nothing to it.

    Use the rename command in PHP to move the file where you want it.

    
    rename($img['tmp_name'],'files/'.$vNameID.'.ext');
    
    PHP:
     
    tandac, Aug 26, 2007 IP