/    Sign up×
Community /Pin to ProfileBookmark

bokeh’s uploader – slight amendment

I used bokeh’s uploader tute’ to make an uploader that keeps a log in mysql which keeps track of the file names and then calls them back (an image gallery). Only thing is when I upload, the files all have weird numbers prefixing the filename “1141744557-test.gif” for example. Can anyone tell me what these numebr are, why they’re there and what my options are to get rid of them?
Thanks

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@jogolMar 08.2006 — the number is there so you don´t overwrite existing files that have the same name. it is done here:

[code=php]// make a unique filename for the uploaded file and check it is not already
// taken... if it is already taken keep trying until we find a vacant one
// sample filename: 1140732936-filename.jpg
$now = time();
while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name']))
{
$now++;
} [/code]


greetz
Copy linkTweet thisAlerts:
@bokehMar 08.2006 — You can do as you please with the naming of the files. I chose to prefix the filename with a unix timestamp. The benifits are many. First the filenames will be unique; when doing a directory read the files will be listed in the order they were uploaded; and even if we are not using a database it is still simple to go into the image directory and get a list of files that were uploaded between two specific dates.
Copy linkTweet thisAlerts:
@DoppleauthorMar 13.2006 — Thanks. I see that now. I was just putting the original file name into the database! much appreciated guys.
×

Success!

Help @Dopple spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...