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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Location
    Milwaukee, Wisconsin
    Posts
    123
    Thanks
    1
    Thanked 0 Times in 0 Posts

    making a random and unique file name???

    im making an uploadingsystem for my staff and i was wondering how you ould make an image file have a unique number name alos so that it has that same name in a databasa...

    im not sure if i made that clear enough if not just ask ill give more detail.

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,045
    Thanks
    10
    Thanked 93 Times in 91 Posts
    If your database table has a unique index then you can name the image using that index.... eg


    again assuming there is an autoindexed field in your table
    PHP Code:
    <?
    $res
    =mysql_query("INSERT INTO $table ($fields)VALUES($values)");
    $im_name=mysql_insert_id();
    ?>

    now $im_name contains the 'id' of your insert and you can name the image with that.

    else look at http://www.php.net/uniqid which will create a unique ID for you.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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