0

I have a simple website on which I want to display the modification date of a specific file in a text element on the websites body. Below is some code I have but it's meant for multiple files. I am pretty new to this so I cant seem to figure out how to get the attributes of one specific file on the server.

<script type="text/javascript" charset="utf-8">

            if (window.File && window.FileList && window.FileReader)
            {
                /************************************ 
                * All the File APIs are supported. * 
                * Entire code goes here.           *
                ************************************/

                function listFileProperties(event) 
                {
                    /* Read the list of the selected files. */
                    var files = event.target.files; 

                    /* Read each file and list down the properties in a table. */
                 var output = "<table><tr><td>Filename</td><td>File Type</td><td>File Size</td><td>Last Modified Date</td></tr>";

                  for (var i = 0, f; f = files[i]; i++) 
                 {
                      output += "<tr><td>" + escape(f.name) + "</td>";       /* f.name - Filename  */
                      output += "<td>" + f.type  + "</td>";                  /* f.type - File Type */
                      output += "<td>" + f.size + " bytes</td>";             /* f.size - File Size */
                      output += "<td>" + f.lastModifiedDate + "</td></tr>";  /* f.lastModifiedDate - Last Modified Date */
                    }

                    output += "</table>";
                    document.getElementById('list').innerHTML = output;  

                    alert(output); 
                }

            } 
            else 
            {
                alert('Sorry! your browser does not support HTML5 File APIs. Therefor the files date cannot be displayed');
            }

</script>

Some help would be greatly appreciated! Thanks a lot!

freshking
  • 1,824
  • 18
  • 31

2 Answers2

0

You'll need to send it the same way as you send the file to the server. You can for example fill out a hidden field in your form as answered here: How to get the last modified date of the uploaded file?

Community
  • 1
  • 1
Krab
  • 2,118
  • 12
  • 23
0

Based on the comment, there is a completely different answer to a completely different question. :-)

The HTML 5 File API is a client-side one. That means you can use it to inspect the files the user puts into your application.

In order to read the details about your server, the server needs to expose them. Now, how to do it will depend mostly on the technology you use at server side.

Krab
  • 2,118
  • 12
  • 23