ikscher
(Ikscher)
June 21, 2011, 8:44am
1
view: test.php
<form enctype="multipart/form-data" id="file-form" action="/hznsvn/trunk/hzn/index-test.php/about/aboutus" method="post">
<input name="is_image" value="1" id="is_image" type="hidden" /> <input id="ytFile_pic_name" type="hidden" value="" name="File[pic_name]" /><input name="File[pic_name]" id="File_pic_name" type="file" />
<input class="save_btn" style="margin-left:40px" type="submit" name="yt0" value="上传形象照" />
</form>
controller :
echo $this->getPost(‘is_image’); // [color="#FF8C00 "]why i can’t access the value ‘1’ from the test.php [/color]
$this->render(‘test’);
note: here is the definination of getpost ,as the following,
public function getPost($name, $defaultValue=null){
return Yii::app()->getRequest()->getPost($name,$defaultValue);
}
any help be appreciated!!!
Gasim
(G Gasimzada)
June 21, 2011, 1:09pm
2
ikscher:
view: test.php
<form enctype="multipart/form-data" id="file-form" action="/hznsvn/trunk/hzn/index-test.php/about/aboutus" method="post">
<input name="is_image" value="1" id="is_image" type="hidden" /> <input id="ytFile_pic_name" type="hidden" value="" name="File[pic_name]" /><input name="File[pic_name]" id="File_pic_name" type="file" />
<input class="save_btn" style="margin-left:40px" type="submit" name="yt0" value="上传形象照" />
</form>
controller :
echo $this->getPost(‘is_image’); // [color="#FF8C00 "]why i can’t access the value ‘1’ from the test.php [/color]
$this->render(‘test’);
note: here is the definination of getpost ,as the following,
public function getPost($name, $defaultValue=null){
return Yii::app()->getRequest()->getPost($name,$defaultValue);
}
any help be appreciated!!!
Did you submit the form? If you do, it should work because before submit the $_POST array is empty. And here is the getPost function. its returning null in your case because you probably didn’t submit it.
public function getPost($name,$defaultValue=null)
{
return isset($_POST[$name]) ? $_POST[$name] : $defaultValue;
}