I have the following code
$image_path = $_FILES["p_image"]["name"].time();
it names the file image02.jpg1335279888
but i want it to be named image02_1335279888.jpg
How can I achieve that?
Simply concat "_" + System. currentTimeMillis() to the filename ? If instead of the milliseconds you want the intellegible timestamp, simply use a DateFormat as shown in the other answer.
The move_uploaded_file() function moves an uploaded file to a new destination. Note: This function only works on files uploaded via PHP's HTTP POST upload mechanism. Note: If the destination file already exists, it will be overwritten.
php $NameOriginal = $_FILES["UploadFileName"]['name']; $Typo_Image = $_FILES["UploadFileName"]['type']; $name_Temp = $_FILES["UploadFileName"]['tmp_name']; ?>
$path_parts = pathinfo($_FILES["p_image"]["name"]);
$image_path = $path_parts['filename'].'_'.time().'.'.$path_parts['extension']
You can check this one:
$file = $_FILES["p_image"]["name"];
$array = explode('.', $file);
$fileName=$array[0];
$fileExt=$array[1];
$newfile=$fileName."_".time().".".$fileExt;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With