when i use below code, subfolder is creating and file is going inside that. But when i edit the record, edit page shows File not found.
"uploads/" .$this->UPLOAD_FIELD_NAME->CurrentValue."/"
The folder name should better not have the dot and the extensions, you can change the folder name to the filename without the extensions.
For example:
"uploads/" .substr($this->UPLOAD_FIELD_NAME->CurrentValue, 0, strrpos($this->UPLOAD_FIELD_NAME->CurrentValue,"."));
When I use below code, subfolder itself not creating. File is saving into 'uploads' folder itself.
"uploads/" .$this->UPLOAD_FIELD_NAME->DbValue."/"
If you refer to the Update() method of the generated code, the DbValue does not available in the update process, so your folder name becomes empty.
You can use $this-><Field>->Upload->FileName to get the uploaded file name during update. But in View Page or List Page, $this-><Field>->Upload->FileName will not have value, So you cannot get the correct folder name.
So you better write a global function (placed in server side Global Code) to get the filename in the different situation and then return it to the folder path.
For example: (Note: assume not multiple upload)
function functionname() {
$page = CurrentPage();
if ($page->IsInsert() || $page->IsUpdate()) {
$filename = $page-><Field>->Upload->FileName;
} else {
$filename = $page-><Field>->CurrentValue;
}
return substr($filename, 0, strrpos($filename,"."))
}
Then you can setup the folder path as : "upload/" . functionname() . "/";
But the better way is not to use the filename as the dynamic folder name as the folder will unnecessarily varies with the file name.