Jump to content


Form upload filenames


1 reply to this topic

#1 ottomatic

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 30 September 2005 - 01:26 PM

I have this form that uploads files. But I want to rename the file that gets uploaded.

$_FILES['filetoupload']['name'];

Which echos "filename.pdf" and that is all well and good. But I would like the file name to be for example... "nun4umxymv3-93.pdf"

the string of letters and numbers are random from a function and the last two numbers are the id number of the record that contains this uploaded file. How do I change the name of the file that gets uploaded but will keep the extension?

Edited by ottomatic, 30 September 2005 - 01:26 PM.


#2 ottomatic

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 30 September 2005 - 02:30 PM

nm, I figured it out..

I did...

$filename = $_FILES['filetoupload']['name'];
$ext = explode('.',$filename);

$filename = $randomNumber."-".$id.".".$ext[1];





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users