Replacing substring in a string
Posted
by user177785
on Stack Overflow
See other posts from Stack Overflow
or by user177785
Published on 2009-09-27T05:26:27Z
Indexed on
2010/05/19
5:50 UTC
Read the original article
Hit count: 247
I am uploading a image file to the server. Now after uploading the file to the server I need to rename the file with an id, but the extension of the file should be retained.
Eg: if I upload the file image1.png then my server script should retain the extension .png
. But I need to change the substring to some other substring (primary key of db).
image1.png
should be renamed to 123.png
image2.jpg
should be renamed to somevalue.jpg
The image can be of any extension like .png
, .jpg
, .jpeg
etc.
I want to rename then in such a way that the image/file extension should be retained.
© Stack Overflow or respective owner