안녕하세요 저는 사이트 구현에 프레임 워크 cakephp를 사용하고 있습니다. 내 현재 PHP 스크립트에서이 오류가 나타납니다 : 정의되지 않은 오프셋 : 1 및 해당 이미 내게 두통을 제공합니다. 내가 잘못하고있는 것을 도와 줄 수 있니?cakephp에서 정의되지 않은 오프셋 : 1
내 코드는 여기에 있습니다 :
이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]; 그것은 저에게 오류를주고있었습니다. 수 시간의 연구로 나는 (isset ($ target_path)) $ target_path = $ location이라면 이것을 \t \t \t \t \t 으로 바 꾸었습니다. $ new_name. "."$ ext [1]; else $ target_path = ''; 이제는 더 이상 오류가 없습니다 : D – electricfeel1979