heamon
(Heamon Guo)
1
When I use CActiveForm to upload photo, write the form like
<div class="row">
[indent]<?php echo $form->labelEx($model,‘product_img’); ?>
<?php echo $form->fileField($model, ‘product_image’, array(‘id’=>‘product_image’)); ?>
<?php echo $form->error($model,‘product_img’); ?>[/indent]
</div>
In controller use $_FILES[‘product_img’] to get the file, but it always said there’s no index of product_img
Any helper is welcome!
heamon
(Heamon Guo)
3
Here’s var_dump got:
array(1) {
["product"]=>
array(5) {
["name"]=>
array(1) {
["product_img"]=>
string(21) "sports_zone_large.png"
}
["type"]=>
array(1) {
["product_img"]=>
string(9) "image/png"
}
["tmp_name"]=>
array(1) {
["product_img"]=>
string(14) "/tmp/phpXvBHtq"
}
["error"]=>
array(1) {
["product_img"]=>
int(0)
}
["size"]=>
array(1) {
["product_img"]=>
int(691)
}
}
}
But why each item stored with array, and when use upload extension, it always said can’t use a array like in trim or strtolower
mech7
(Chris De Kok)
4
In your model (or controller )you can access it like:
$this->pdf = CUploadedFile::getInstance($this, ‘pdf’);
$this->pdf->saveAs($new_pdf);