-1
您好我一直在探索使用框架cakephp来实现网站。在我目前的PHP脚本中出现这个错误:Undefined offset:1,它已经给我头痛了。你们能帮我解决我做错了什么吗?未定义的偏移量:1在cakephp中
我的代码是在这里:
function file_upload($file_array, $id){
if(count($file_array))
{
$location = "files/library-files/";
foreach ($file_array as $file) {
$ext = explode(".", $file['name']);
$new_name = md5(uniqid());
$target_path = $location . $new_name .".".$ext[1];
if(move_uploaded_file($file['tmp_name'], $target_path))
{
$this->LibraryFiles->create();
$this->LibraryFiles->set('id', $new_name);
$this->LibraryFiles->set('library_id', $id);
$this->LibraryFiles->set('name', $file['name']);
$this->LibraryFiles->set('ext', $ext[1]);
$this->LibraryFiles->set('type', $file['type']);
$this->LibraryFiles->set('size', $file['size']);
if($this->LibraryFiles->save())
{
}
else
{
}
}
}
}
}
有没有在你的文件排列的文件,而无需点内,或指向上一级目录? –
它是这一行$ target_path = $ location。 $ new_name。“。”。$ ext [1];那给了我错误。我用几小时的研究取代了它\t \t \t \t \t if(isset($ target_path))$ target_path = $ location。 $ new_name。“。”。$ ext [1]; else $ target_path ='';现在没有更多的错误:D – electricfeel1979