Ryoku Posted August 21, 2008 Share Posted August 21, 2008 Coming hot off the heels of the last post I made is a branched problem. I have my file uploading working currently. It renames and posts correctly however the formatting is incorrect. I have my formatting set up so that it is supposed to rename a file to the fallowing format Date.postid.ext [date(Ymd).’-‘.$postid.$ext] which outputs 20080808-2.jpg At first glance this looks correct however in my DB I want to have a padding to accommodate up to 10k posts to accomplish that and maintain organization I want to pad the number with “0” until it has the correct number of characters. (so an example of correct formatting would be 20080808-00002.jpg) Every time I have asked this people say to use the str_pad() function however I can’t seem to get it to work because when i echo it the string becomes an int and i lose my padding again. I know I'm probably doing it wrong. Can someone give me an example of how to work with integer padding? Quote Link to comment Share on other sites More sharing options...
ratcateme Posted August 21, 2008 Share Posted August 21, 2008 try this when you create the final name and turn it into a string date(Ymd).’-‘.str_pad($postid, 5, "0", STR_PAD_LEFT).$ext Scott. Quote Link to comment Share on other sites More sharing options...
Ryoku Posted August 21, 2008 Author Share Posted August 21, 2008 its worked but i got a weird result, when i uploaded the file i had to change the '-' to "-" or it didn't accept the formatting... that's kind of odd... thank you for your help! Ryoku Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.