...
For more detail about this component, let see at: /PF.Base/module/core/include/component/controller/upload-temp.class.php
...
...
Click on remove file with remove uploaded file and call ajax function core.removeTempFile
...
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
<?php public function add($aVals,$bIsUpdate = false) { $aInsert = [ 'name' => $aVals['name'], 'description' => $aVals['description'], 'time_update' => time(), // last modification time 'privacy' => $aVals['privacy'], // public ]; if ($bIsUpdate) { $aTodo = db()->select('*')->from(':todolist_task')->where('task_id = '.$aVals['task_id'])->execute('getRow'); //When edit a todo task, we need to check and remove old photo if user upload new photo or delete current photo if (!empty($aTodo['image_path']) && (!empty($aVals['temp_file']) || !empty($aVals['remove_photo']))) { if ($this->deleteImage($aVals['task_id'],$aTodo['user_id'])) { $aInsert['image_path'] = null; $aInsert['server_id'] = 0; } else { return false; } } } //$aVals['temp_file'] is id of temporary file was saved in `phpfox_temp_file` table, this is file you just uploaded if (!empty($aVals['temp_file'])) { //Get detail of this file $aFile = Phpfox::getService('core.temp-file')->get($aVals['temp_file']); if (!empty($aFile)) { //Set value for `image_path` and `server_id` column based on data of temp file $aInsert['image_path'] = $aFile['path']; $aInsert['server_id'] = $aFile['server_id']; //Remove this temporary row in `phpfox_temp_file` table Phpfox::getService('core.temp-file')->delete($aVals['temp_file']); } } if ($bIsUpdate) { // update to do item db()->update(':todolist_task', $aInsert, ['task_id' => $aVals['task_id']]); if ($aVals['privacy'] == '4') { Phpfox::getService('privacy.process')->update('todo', $aVals['task_id'], (isset($aVals['privacy_list']) ? $aVals['privacy_list'] : array())); } } else { $aInsert['time_stamp'] = time(); $aInsert['user_id'] = Phpfox::getUserId(); // Insert to do item database $iItemId = db()->insert(':todolist_task', $aInsert); if ($aVals['privacy'] == '4') { Phpfox::getService('privacy.process')->add('todo', $iItemId, (isset($aVals['privacy_list']) ? $aVals['privacy_list'] : array())); } Phpfox::getService('feed.process')->add('todo', $iItemId, 0, 0); } } ?> |
$aVals&['remove_photo'] with
remove_photo
is value of paramremove_field_name
$aVals&['temp_file'] with
temp_file
is value of paramfield_name
...