?

Log in

No account? Create an account
Slightly improved file uploader - 'Twas brillig, and the slithy toves did gyre and gimble in the wabe [entries|archive|friends|userinfo]
Thomas

[ website | Beware the Jabberwock... ]
[ deviantArt | the-boggyb ]
[ FanFiction | Torkell ]
[ Tumblr | torkellr ]

Links
[Random links| BBC news | Vulture Central | Slashdot | Dangerous Prototypes | LWN | Raspberry Pi]
[Fellow blogs| a Half Empty Glass | the Broken Cube | The Music Jungle | Please remove your feet | A letter from home]
[Other haunts| Un4seen Developments | Jazz 2 Online | EmuTalk.net | Feng's shui]

Slightly improved file uploader [Thursday 20th November 2014 at 8:55 pm]
Thomas

boggyb
[Tags|, ]
[Feeling |accomplishedaccomplished]
[Playing |Ralph McTell - Spiral Staircase [The Best of]]

Anyway, enough ranting about nutters on the road. Remember the file uploader I hacked together earlier this year? Well, I discovered a slight flaw when using it with the Wii U - the filename provided by the console is static, and so later uploads overwrite earlier ones. That's easily fixed...



The change is only a few lines - the call to move_uploaded_file has been replaced with

      $pathinfo = pathinfo($_FILES['file']['name'][$i]);
      $dest = $pathinfo['filename'] . strftime('-%Y%m%d-%H%M%S.') . $pathinfo['extension'];
      move_uploaded_file($_FILES['file']['tmp_name'][$i], $dest);


The result is each uploaded file has the current date and time appended to it (for example, vorpal.jpeg becomes vorpal-20141120-205045.jpeg). Obviously this will still overwrite files if you manage to upload the same filename multiple times within the same second, to which my answer is meh! As before, feel free to use it under the 3-clause BSD license.
Link | Previous Entry | Share | Next Entry[ 2 pennies | Penny for your thoughts? ]

Comments:
From: shozabred
Thursday 20th November 2014 at 9:08 pm (UTC)
no license! copyleft rules
(Reply) (Thread)
[User Picture]From: boggyb
Thursday 20th November 2014 at 9:20 pm (UTC)
I was tempted to use the WTFPL...
(Reply) (Parent) (Thread)