Member Avatar for bben95

What I want to do is to rename a particalar file that is ftp'd to the server into a certain folder which I will call "raw" and have that file renamed to "image.jpg" in the folder "webcam" but the file uploaded by the webcam is different every time because the webcam puts the time and date in the filename. So far I have worked out this:

<?php rename("/home/a6773990/public_html/webcam/raw/"'*',"/home/a6773990/public_html/webcam/webcam/image.jpg"); ?> [/CODE=PHP][CODE=PHP]
<?php
rename("/home/a6773990/public_html/webcam/raw/"'*',"/home/a6773990/public_html/webcam/webcam/image.jpg");
?>
[/CODE=PHP]

I'm not clear if you are wanting the most recent file, but you can read the directory (http://www.php.net/manual/en/function.readdir.php) to get the filenames. If you are looking for the filename with the highest sequence number, then you can store the filename if its greater than the stored filename.
If you are needing to look for the most recent file, then use the "stat" function (http://us2.php.net/manual/en/function.stat.php) on each file to get the timestamp and store the filename with the most recent timestamp.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.