1. Home
  2. Computing & Technology
  3. PHP / MySQL
photo of Angela Bradley

Angela's PHP / MySQL Blog

By Angela Bradley, About.com Guide to PHP / MySQL

Renaming PHP Uploads

Thursday July 24, 2008
If you are allowing people to upload to your server, you may want to rename the files before they are saved to give them the appropriate prefix, or just to make sure the file name is unique. This script shows you how to rename files uploads.

Comments

July 26, 2008 at 4:30 am
(1) microsoftsea says:

go day boat america green boy minor busy america boy house

July 30, 2008 at 1:51 pm
(2) deathisonitsway says:

hi everybody ; I have a shortcut about rename file :=)

if(preg_match(’/(.*)\.(.*)/’,$_FILES[’afis’][’name’],$dizi) ) {

$format=$dizi[2];

}

$ids=mysql_query(”select id from film_info order by id desc limit 1″);

$ids_get=mysql_fetch_assoc($ids);

$id_f=$ids_get[’id’]+1;

$new_name=”".$id_f.”_afis.”.$format.”";

// degisen ad

$_FILES[’afis’][’name’]=$new_name;

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL

©2008 About.com, a part of The New York Times Company.

All rights reserved.