I upload an XML file to migrate its contents to my database, but I want firstly store the last modified date of that file to assure that no change has happened to that file from
This information is never sent to the server when you use a file input to upload a file. Only the filename, mime type and contents are sent with multipart/form-data
. You could use the HTML5 File API to obtain this information from the file before uploading it.
As requested in the comments section here's an example of an ASP.NET page which has an upload control and a hidden field which will be used to store and send the file last modified date to the server using the HTML5 File API:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Globalization" %>
So in this example we subscribe for the onchange
event of the file input and if the client browser supports HTML5 File API we can obtain information about the selected file such as its name, size, last modified date, ... In this example we store the last modified date into a hidden field so that this information is available on the server once we upload the file.