簡體   English   中英

PHP重命名功能問題

[英]PHP rename function problem

我正在嘗試使用php重命名功能將服務器上的文件從一個文件夾移動到另一個文件夾,但出現此錯誤

警告:重命名(/home/pramiro/public_html/new/cipri/adauga/tmp/Koala.jpg、/home/pramiro/public_html/new/images/memo/Koala.jpg)[function.rename]:無此類文件或第13行的/home/pramiro/public_html/new/cipri/adauga/categorie.php中的目錄

路徑很好,文件夾存在並且要復制的文件在tmp文件夾中。我怎么可能做錯了?

這是代碼:

$filename=$_POST['poza_conv'];
$filename=substr($filename,37);
$old_path='/home/pramiro/public_html/new/cipri/adauga/tmp/'.$filename;
$new_path=' /home/pramiro/public_html/new/images/';
switch($_POST['categorie_conv'])
{
    case 'memo': $filename=$new_path.'memo/'.$filename;
    break;
    case 'ort_sup': $filename=$new_path.'ort_sup/'.$filename;
    break;
}

rename($old_path,$filename);

這是您的錯誤:

$new_path=' /home/pramiro/public_html/new/images/';

/home之前有一個前導空格,這會導致錯誤,因此應該是:

$new_path='/home/pramiro/public_html/new/images/';

如果仍然出現該錯誤,那么就像其他人所說的那樣,下一個最可能的罪魁禍首是權限,尤其是在您要在其間移動文件的目錄以及文件本身上。

權限可能? PHP腳本可能不在您自己的用戶帳戶下運行,並且如果PHP用戶沒有讀取文件的權限,PHP將看不到它們。

目標路徑/home/pramiro/public_html/new/images/memo/確實存在? 該錯誤表明事實並非如此。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM