Slightly improved file uploader
Nov. 20th, 2014 08:55 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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
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.
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.