I am uploading the files to the folder by using file_save_upload
and file_move
to achieve this. Its working fine but a problem arises while saving in database. I have used FILE_EXISTS_RENAME
argument, so in file_managed
table filename
column and uri
column file name is not same. In filename
column its not appending the integer value, but in uri column its appending the integer value since the file is already exist. Below is my code:
for ($i = 0; $i < $num_files; $i++) {
$file = file_save_upload($i, $validators, FILE_EXISTS_RENAME);
if ($file) {
$file->status = FILE_STATUS_PERMANENT;
if ($file = file_move($file, 'public://feed-files/' . $foldername, FILE_EXISTS_RENAME)) {
$form_state['values']['file'][$i] = $file;
}
else {
form_set_error('file', t('Failed to write the uploaded file to the selected folder.'));
return FALSE;
}
}
else {
form_set_error('file', t('No file was uploaded.'));
return FALSE;
}
}
below is the database values:
So how can achieve that filename
and uri
column file name should be same. Any suggestions will be appreciated.