我正在整理文件夹,但由于权限的限制,我无法移动文件,但是当我检查时,正在创建文件夹,正在移动文件,并且上层文件夹与同一用户和组apache:apache
相关联。我也正在与apache
用户一起运行此php代码。可能是什么问题?
快速查看;
exec('mv '.$path.$result->token.'-*.mp4 '.$path.getWeekNo($result->date).'/ 2>&1', $moveOut, $moveResult);
代码:
function processFilesByID($db, $path, $id, $type ='token')
{
$result = $db->get_row('SELECT id,token,title,date FROM DB_TABLE where id="' . $id . '";');
/* Debug - Start */
$db->debug();
// return "ID: " . $result->id . "<br />Token: " . $result->token . "<br />Title: " . $result->title . "<br />Date: " . $result->date;
/* Debug - End */
if (isset($result)) {
// Check if any file exists with given token command.
exec('ls -1 ' . $path . $result->token . '-* | wc -l', $out, $res);
// Check if noOfFile is greater than 0 and less than 10. Also check if command succeed.
if ($res == 0 && $out[0] > 0 && $out[0] < 10) {
// Move its media files [WHERE PROBLEM OCCURS]
exec('mv '.$path.$result->token.'-*.mp4 '.$path.getWeekNo($result->date).'/ 2>&1', $moveOut, $moveResult);
if($moveResult == 0){
// Double check if it's moved succesfully.
exec('ls -1 ' . $path.getWeekNo($result->date).'/'. $result->token . '-* | wc -l', $newOut, $newRes);
if ($newRes == 0 && $newOut[0] > 0 && $newOut[0] < 10) {
// Update DB with new path
if($db->query("UPDATE DB_TABLE SET token = '".getWeekNo($result->date).'/'.$result->token."' WHERE id= '".$result->id."'")){
}else{
}...
输出
Array
(
[0] => mv: cannot move '/###PATH###/+++FILE-NAME1+++' to '/###PATH###/16401c4a73848b7be4720d2e13a50a430c7b/+++FILE-NAME1+++': Permission denied
[1] => mv: cannot move '/###PATH###/+++FILE-NAME2+++' to '/###PATH###/16401c4a73848b7be4720d2e13a50a430c7b/+++FILE-NAME2+++': Permission denied
[2] => mv: cannot move '/###PATH###/+++FILE-NAME3+++' to '/###PATH###/16401c4a73848b7be4720d2e13a50a430c7b/+++FILE-NAME3+++': Permission denied
)
我也尝试使用php的内置命令,但到目前为止还没有运气。