Jump to content

how to change the name of images with different extensions


php_guest

Recommended Posts

Even easier, just simple pathinfo('$filename'). Sorry to not check this before I put the question.

 

So I put this code to change image name to put it into database:

 

$ext = pathinfo('$filename');

 

$len = 16;

$base='ABCDEFGHKLMNOPQRSTWXYZabcdefghjkmnpqrstwxyz123456789';

$max=strlen($base)-1;

$string='';

mt_srand((double)microtime()*1000000);

while (strlen($string)<$len+1)

  $string.=$base{mt_rand(0,$max)};

 

$newname=$string.".".$ext['extension'];

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.