Title: Insert date into upload path
Last modified: March 11, 2017

---

# Insert date into upload path

 *  Resolved [jlohl](https://wordpress.org/support/users/jlohl/)
 * (@jlohl)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/insert-date-into-upload-path/)
 * Hello,
    is it possible to automatically insert date, ie date(“d-m-y”) into upload
   path ? At the moment, I added to the path a user field /%username%/%userdata2%
   with userdata2 being date. This works but I’d like to have the real date in the
   path instead of a date choosen by the user.
 * Thanks for help.
    JL

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [nickboss](https://wordpress.org/support/users/nickboss/)
 * (@nickboss)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/insert-date-into-upload-path/#post-8902551)
 * Hi, this is not so straightforward. You need some Javascript tweaks. Here is 
   the code below. You need to put it inside the page, right below the shortcode.
   This code will hide the second date field (so that the user cannot fill it) and
   it will be populated automatically with the current date.
 *     ```
       <script type="text/javascript">
       document.getElementById("userdata_1_1").style.display = "none";
       Code_Initializators[Code_Initializators.length] = function(sid) {
       	var Code_Object = {};
       	Code_Object.pre_start = function () {
       		var d = new Date();
       		document.getElementById("hiddeninput_1_userdata_1").value = ('0'+d.getDate()).slice(-2)+'-'+('0'+(d.getMonth()+1)).slice(-2)+'-'+('0'+d.getFullYear()).slice(-2);
       	}
       	return Code_Object;
       }
       </script>
       ```
   
 * Regards
 * Nickolas
 *  Thread Starter [jlohl](https://wordpress.org/support/users/jlohl/)
 * (@jlohl)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/insert-date-into-upload-path/#post-8903021)
 * Thank you Nickolas, it works fine.
    I thought that a simpler solution would be
   available with some hook. Regards JL
    -  This reply was modified 9 years, 3 months ago by [jlohl](https://wordpress.org/support/users/jlohl/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Insert date into upload path’ is closed to new replies.

 * ![](https://ps.w.org/wp-file-upload/assets/icon-256x256.png?rev=3252590)
 * [Iptanus File Upload](https://wordpress.org/plugins/wp-file-upload/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-file-upload/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-file-upload/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-file-upload/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-file-upload/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-file-upload/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [jlohl](https://wordpress.org/support/users/jlohl/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/insert-date-into-upload-path/#post-8903021)
 * Status: resolved