2012-12-20 3 views
0

을 통해 파일 데이터 배열을 가져올 수 없습니다. 일반적으로 $ this-> request-> data에서 필요한 모든 데이터를 가져옵니다. 하지만 아약스 파일 업로드를 사용하고 있다면, 해당 데이터의 예 얻을 수 없습니다 tmp_name, 크기 등을

내 자바 스크립트 코드 같은 것입니다 :

function uploadFile(file_blob_chunk, file_name, file_part, total_file_chunk, file_id) { 
fd = new FormData(); 
    fd.append("file_for_upload", file_blob_chunk); 
    fd.append("somestring", "This is some extra data"); 

    xhr = new XMLHttpRequest();    
xhr.open("POST", "files/index/" + file_id + '/' + file_part, true); 

//Onload happened after file finished uploaded 
xhr.onload = function(e) { 
    //alert(file_name + "done");  
}; 

xhr.upload.addEventListener("progress", function(evt) {   
    if (evt.lengthComputable) { 
    }}, false); 

xhr.send(fd); 
} 

및 FilesController.php에서

내가

debug($this->request->data); 

가 난 단지

를 얻을 것이다 사용하는 경우
public function index($file_id = null, $file_part = null) { 
    if ($this->request->is('post')) { 
     //I can't use $this->request->data, to get the file details 
    } 
} 

array(
    'somestring' => 'This is some extra data' 
) 

나는 파일 데이터

임 사용하지 않는 디버그 ($ _ FILES) 당신이해야 $this->request->data 게시물 데이터를 사용하려면, 내가

array(
    'file_for_upload' => array(
     'name' => 'blob', 
     'type' => 'application/octet-stream', 
     'tmp_name' => 'C:\xampp\tmp\phpAC42.tmp', 
     'error' => (int) 0, 
     'size' => (int) 9304862 
    ) 
) 
+0

이동이 data[Model][some_field]

: 형식 케이크 예를 들어, 기대? [Superglobals] (http://php.net/manual/en/language.variables.superglobals.php) "프레임 워크"가 그들을 제거하지 않는다고 가정하십시오. – ficuscr

답변

0

을받지 않습니다를 얻을 수 없다 당신은 소스에 CustomField

+0

나는 그것을 오해한다고 생각한다. "CustomField"는 단지 문자열이다. 나는 내 게시물 pls를 점검 할 것이다. – Harts

+0

'data [Model] [some_field]'는 단지 문자열이다. 유일한 차이점은'data [Model] [some_field]'는 케이크 형식이고'customField'는 그렇지 않다는 것입니다. – dogmatic69

+0

아니, 나는 $ this-> request-> data를 사용하면 customfield (텍스트를 "somestring"로 바꾼다)를 얻을 수 있다는 것을 의미한다. "file_for_upload"를 얻지 못할 것이다. – Harts

관련 문제