0

警告:重命名(k.jpg,)[function.rename]:第 15 行的 C:\xampp\htdocs\xampp\uploader.php 中没有错误

我不断收到此错误,即使文件不断移动到正确的文件夹中...

$target_path = "schlImage/";
$school_name= $_SESSION["school_username"];
$nm=$_FILES['uploadedfile']['name'];

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
} else {
    echo "There was an error uploading the file, please try again!";
}

rename($nm,$school_name);
4

1 回答 1

0
rename($nm,$school_name);

change to

$co = substr_count($nm,'.');
$ex = explode('.',$nm);
rename($target_path,"schlImage/".$school_name.".".$ex[$co]);

See rename php function

于 2013-05-04T09:41:42.923 回答