while uploading i want to rename the image name to date and time.i have a code like this

date_default_timezone_set('UTC');
$today = date("Y-m-d");
$_SERVER['REQUEST_TIME'];
$dt = $today.'_'.time();
$uploadDir = '/upimg/logoimg/'.$dt.'';

$filename = $_FILES['logoimage']['name'];
    $tmpname = $_FILES['logoimage']['tmp_name'];

    $filePath = $uploadDir . $filename;
    $result1 = move_uploaded_file($tmpname, $filePath);

after uploading that image path is like date_time_imagename

    /upimg/logoimg/2014-04-09_139704740331BG-NHTB-AGUMBE1_1098618g.jpg

instead of that i want to display date and time only

one of the many ways of doing this is to get the image file extension first.

for example,

$this_ext = pathinfo($filename, PATHINFO_EXTENSION);

The above codes will give us the image extension of the uploaded image.

The next step is to rename the image

$result1 = move_uploaded_file($tmpname, $uploadDir.'.'.$this_ext);

image is not stored in server by using this
$this_ext = pathinfo($filename, PATHINFO_EXTENSION);
The above codes will give us the image extension of the uploaded image.

The next step is to rename the image

$result1 = move_uploaded_file($tmpname, $uploadDir.'.'.$this_ext);

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.