How to duplicate image file in the same folder i want to duplicate a image file in the same folder programmatically , so i'm used file_copy() function for this but the original file image replaced or renamed and in file_managed table on database no row created.

if ($form_state['values']['image'] != 0) {
            $fileo = file_load($form_state['values']['image']);
            $fileo -&gt; status = FILE_STATUS_PERMANENT;
            $file = file_copy($fileo,'public://img_files/',FILE_EXISTS_RENAME );
            file_usage_add($file, 'image', 'file_img', 1);
        } 


Thank you :).
To add entry for a file to a file_managed table, you could use code like:

global $user;
$file = new stdClass;
$file-&gt;uid = $user-&gt;uid;
$file-&gt;filename = 'image.png';
$file-&gt;uri = 'public://path/to/file/image.png';
$file-&gt;status = 1;
$file-&gt;filemime = 'image/png';
file_save($file);
file_usage_add($file, 'mymodule', 'mykindofusage', $node-&gt;nid);


Code shamelessly stolen from this answer by Clive.

Now, if you are using a file_copy function, it should work all right and create these entries for you. But you should always check what's in return value ($file in your case). If it's FALSE, you should not call file_usage_add, but output a message to check watchdog entries for failure reason.

If you will tell us what's in your watchdog, probably in another question, we'll be able to answer with more details about the reason of failuer.