我想用jaditable和ajaxupload,你可以看到一個演示here。我在一個Zend視圖文件,如下所示使用這個插件:ajaxupload jeditable和zend框架
JS代碼
$(".ajaxupload").editable("<?php echo $this->baseUrl('/inside/students/update-student'); ?>", {
indicator : "<img src='<?php echo $this->baseUrl('img/indicator.gif'); ?>'>",
type : 'ajaxupload',
submit : 'Upload',
cancel : 'Cancel',
tooltip : "Click to upload..."
});
HTML代碼
<img class="left-floating-image=" src="<?php echo $this->baseUrl($this->user['img_path']); ?>" />
<p id="img_path" class="ajaxupload">Upload</p>
我的PHP代碼在Zend控制器:
public function updateStudentAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
if ($this->_request->isPost()) {
$params = $this->_request->getParams();
Zend_Debug::dump($params);
$field = $params['id'];
$value = $params['value'];
// $userID = Zend_Auth::getInstance()->getIdentity()->id;
//
// $userModel = new Application_Model_Users();
// $userModel->update(array($field => $value), "id = $userID");
echo $value;
}
}
唯一的問題是,當我轉儲POST變量我沒有得到張貼的變量。我只得到這個:
array(3) {
["module"] => string(6) "inside"
["controller"] => string(8) "students"
["action"] => string(14) "update-student"
}
而且有2個錯誤說沒有索引'id'或'value'。我檢查了使用Tamper Data插件發送給服務器的是什麼。這裏是輸出:
21:46:09.886[634ms][total 634ms] Status: 200[OK]
POST http://localhost/industrial/public/inside/students/update-student Load Flags[LOAD_DOCUMENT_URI LOAD_INITIAL_DOCUMENT_URI ] Content Size[540] Mime Type[text/html]
Request Headers:
Host[localhost]
User-Agent[Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12]
Accept[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]
Accept-Language[en-us,en;q=0.5]
Accept-Encoding[gzip,deflate]
Accept-Charset[ISO-8859-1,utf-8;q=0.7,*;q=0.7]
Keep-Alive[115]
Connection[keep-alive]
Referer[http://localhost/industrial/public/inside/students]
Cookie[PHPSESSID=dufubvhd6bihqd4jk5q655bap3]
Post Data:
POST_DATA[-----------------------------215452871217546
Content-Disposition: form-data; name="value"; filename="btn_companies.png"
Content-Type: image/png
PNG
我怎樣才能得到正在發送的文件,如果Zend沒有得到POST_DATA?一旦解決了這個問題,我需要讓這個方法決定提交的數據類型(文本或文件)。