auto upload rename

Started on the old forum in December 2009 · view the original in the archive · old links redirect here

2 replies · 465 views · started 16 years ago · 1 min read

3 participants
kei_ki7 Senior · 431 posts #1
function uploadfile($origin, $dest, $tmp_name)
{
  $origin = strtolower(basename($origin));
  $fulldest = $dest.$origin;
  $filename = $origin;
  for ($i=1; file_exists($fulldest); $i++)
  {
   $fileext = (strpos($origin,'.')===false?'':'.'.substr(strrchr($origin, "."), 1));
   $filename = substr($origin, 0, strlen($origin)-strlen($fileext)).'['.$i.']'.$fileext;
   $fulldest = $dest.$newfilename;
  }
 
  if (move_uploaded_file($tmp_name, $fulldest))
   return $filename;
  return false;
}

i dont know where i can put this in uploader.php i want to make the upload file name will be

kevin_uploadfile.ext

Did I help you? You can help me too Your donations will help me finance my studies.

Mysterio Lead · 630 posts #2

lol bro, i told you that before. i thought you using that code.

$filename = preg_replace("/$filename/", "kevin_".$filename."", $filename);

or you may use $superdat_name instead of $filename, if you have lavalair. And put it on top of page, after the $filename or $superdat_name declaration.

mysterio.al - programming is a functional art

santha26 Junior · 40 posts #3

Is This code only for lava ... How can i use it in auto index script

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close