This topic is locked

rename filename with local time

7/15/2009 3:42:50 AM
PHPRunner General questions
U
uday author

hello ,
i want rename image filenames while uploading with current time, in format %Y-%m-%d %H-%M-%S e.g 2009-07-15 12-00-00 so how can i do it? after rename my file name should be like2009-07-15 12-00-00.jpg.
NOTE : Append timestamp option in'Edit as' is none of use.

U
uday author 7/15/2009

hi

i am able to rename that file but its not able to shown in browser ?

i used following code to rename file name . above code added on event BeforeAdd of AddPage.php
Here 'image' View As Image & Edit as 'File/Image' & in database it taken as VARCHAR(200);
[codebox]$timestamp = strftime("%Y-%m-%d %H:%M:%S %Y");

echo strftime("%Y-%m-%d %H-%M-%S", strtotime("+5 hour"))."<br/>";
foreach( $files_move as $key=>$val)

{

if($val[0]==$_FILES["image"]["tmp_name"])

$files_move[$key][1] = "files".$values["recvdtime"].".png";

}

$values["image"] = $values["recvdtime"].".png";
return true;[/codebox]
But image not displayed ??? after remove rename code & just upload image then image displayed <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=42725&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' /> So whats the Problem?

J
Jane 7/15/2009

Hi,
to open these renamed files edit generated ..._download.php file and edit file name manually. For example find this line:

printfile(GetAbsoluteFileName(GetUploadFolder($field).$filename));



and replace it with this one:

printfile(GetAbsoluteFileName(GetUploadFolder($field).$data["recvdtime"].".png"));

U
uday author 7/15/2009

Hi,

to open these renamed files edit generated ..._download.php file and edit file name manually. For example find this line:



in my case i think its test_download.php i replace mentioned line but its still not working ?? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=42733&image=1&table=forumreplies' class='bbc_emoticon' alt=':o' />
NOTE - Here recvdtime is Datetime field in Database table. & View As DateTime & Edit As Datewith Show time in Datepicker Checked
Is that creating problem ?

J
Jane 7/15/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

U
uday author 7/16/2009

Project uploaded on Demo Account also Ticket raised for same. TICKET ID : - 186421.
Thanks in advance!!!