Click here to Skip to main content
15,886,075 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Is there ever a way possible to get the actual creation / modification time of the file being uploaded, using JavaScript / PHP?

As for JavaScript, I have researched a lot, tried quite a few codes, but to no luck (perhaps trying to do possible out of impossible).

As for PHP, using filectime() and filemtime(), it only shows the date / time the file is uploaded, and not the time the file is actually created / modified on the source.

In short, what I want is to check the m-time of a file before/during/after upload (where-ever possible) and decide whether or not to store the file on the server, and report the same back to the client.

In case you need, here is a snap of HTML/JavaScript code that I fiddled with....
XML
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Experiments</title>
        <script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
        <script type="text/javascript">
            function _do(){
                return true;
            }

            function getLastMod(){
                var myFrm = document.getElementById('myIframe');
                var lastModif = new Date(myFrm.contentWindow.document.lastModified);
                return lastModif.toLocaleString();
            }

            function ShowTempImage(imagePath){
                $("#test").html("<b>Before</b> " + getLastMod());
                $("iframe#myIframe").attr("src",imagePath);
                $("#test").html($("#test").html());
                $("#LastModified").html("<b>Before</b> " + getLastMod());
            }
        </script>
    </head>
    <body>
        <form action="" method="post" enctype="multipart/form-data" onsubmit="return _do()">
            <input type="text" id="txtTest" name="Text" />
            <input type="hidden" id="hidTest" name="Hidden" value="Some value" />
            <input type="file" id="uplTest" name="File" onchange='ShowTempImage(this.value);' />
            <input type="submit" value="Submit" />
        </form>
        Test Value: <span id="test"></span>
        <br />
        Last Modified Date : <span id="LastModified"></span>
        <iframe id="myIframe" onload="" src="C:\\xampp\htdocs\\experiments\\DSC03425.JPG" style="display:block; width: 800px; height: 400px;"></iframe>
        <img src="file:///C:/xampp/htdocs/experiments/DSC03425.JPG" />
    </body>
</html>


Any help please.......

Thanks in advance
Posted
Updated 30-Sep-11 6:13am
v2

1 solution

Hi,

Here I'm providing some link for your requirement .Just check this out

http://www.html5rocks.com/en/tutorials/file/dndfiles/

I'm Using this for my purpose so I hope it helps you also


All the Best
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900