Closed anuj9196 closed 7 years ago
Change place of line 2 with 3
...patchEntity...
line with top line
And why you need to patchEntity
?
because there are some data which is coming from form. I just have to copy same file to a new path, rest data are from form.
changed my code to look like
$path = WWW_ROOT . '..' . DS . $postVideo->dir . DS . $postVideo->video_file;
$newPostVideo = $this->PostVideos->newEntity([
'video_file' => $path,
'campaign_id' => $this->request->getData('campaign_id'),
]);
and changed my column to not null in database, which now gives error as
Error: SQLSTATE[HY000]: General error: 1364 Field 'video_file' doesn't have a default value
Same is working fine for direct uploading. but having problem here
i dont know you can moving file by this plugin or no you can move your file and insert new record by custom code
transaction begin
if(save new record ){
if (move file)
return true//commit
else
return false// roleback
}
As mentioned in documentation
I'm moving files within filesystem.
I have to create a new record with same video file in a separate file just as newEntity does, but instead of uploading file, I have to move a pre-uploaded file withing filesystem
A new record is created in database but
video_file
anddir
fields areNULL
.Files are saved at
and
dir
column has value