imae script

Discussion in 'PHP' started by dean5000v, Dec 23, 2008.

  1. #1
    ok here is a snippet of the script which allows me to upload a image and it will autocreate a thumbnail and save the image into my directory.

    the script at the moment keeps the original file name when it saves it to the thumbnail location which is this part of the code.

    $filename = $_FILES['fupload']['name'];

    now ive added in a simple php function to create a random code like so:

    $random_number = intval( "0" . rand(1,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9));

    but the problem is how to i change the $filename so it changes to the random generate code but also keeps the file extension of the original file.
     
    dean5000v, Dec 23, 2008 IP
  2. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this :

     
    mallorcahp, Dec 23, 2008 IP
  3. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks worked perfectly !
     
    dean5000v, Dec 23, 2008 IP
  4. planemaniac

    planemaniac Peon

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Think of this though:

    If I upload an image to your site called this.is.my.image.jpeg, what's going to happen then?
     
    planemaniac, Dec 23, 2008 IP