을 통해 파일 데이터 배열을 가져올 수 없습니다. 일반적으로 $ 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
)
)
이동이
data[Model][some_field]
: 형식 케이크 예를 들어, 기대? [Superglobals] (http://php.net/manual/en/language.variables.superglobals.php) "프레임 워크"가 그들을 제거하지 않는다고 가정하십시오. – ficuscr