繁体   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