Yii Framework Forum: Upload works, but MultipleUpload does not work! - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Upload works, but MultipleUpload does not work! See page. 109 codes

#1 User is offline   Mikewolf 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 04-January 12

Posted 23 January 2012 - 03:54 PM

hi,

I trying the Multiple upload things, I did the example in 106 single file upload, it works totally fine, then I try to multiple update files like code on page 109, it does not work. looks like there is validate problem, I always get $model->validate() false, with errors like this:
array(1) {
  ["file"]=>
  array(1) {
    [0]=>
    string(21) "File cannot be blank."
  }
}


I am sure, I have choose 3 times file from disk, and click the upload button. I google some, but not find good solution, and btw. code on page 109:
$files = CUploadedFile::getInstance($model, 'file');


man should here use getInstance or getInstances? I am totally confused, Please help. Thank you very much.
Newbee of Yii
0

#2 User is offline   tihanyilaci 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 29-July 11

Posted 07 May 2012 - 01:44 PM

View PostMikewolf, on 23 January 2012 - 03:54 PM, said:

hi,

I trying the Multiple upload things, I did the example in 106 single file upload, it works totally fine, then I try to multiple update files like code on page 109, it does not work. looks like there is validate problem, I always get $model->validate() false, with errors like this:
array(1) {
  ["file"]=>
  array(1) {
    [0]=>
    string(21) "File cannot be blank."
  }
}


I am sure, I have choose 3 times file from disk, and click the upload button. I google some, but not find good solution, and btw. code on page 109:
$files = CUploadedFile::getInstance($model, 'file');


man should here use getInstance or getInstances? I am totally confused, Please help. Thank you very much.


Hi, it does not work for me too. i tried with the getInstances method, it returns an array of files, but it does not work also. The error is file cannot be blank.
0

#3 User is offline   bluyell 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 221
  • Joined: 28-October 11

Posted 08 May 2012 - 11:24 AM

you can use this: http://www.yiiframew...-yii-framework/

is very efficient, and easy to implement.
0

#4 User is offline   nakarin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 08-May 12

Posted 03 June 2012 - 06:59 AM

View Posttihanyilaci, on 07 May 2012 - 01:44 PM, said:

Hi, it does not work for me too. i tried with the getInstances method, it returns an array of files, but it does not work also. The error is file cannot be blank.



IN Upload.php

array('file', 'file', 'types'=>'zip','allowEmpty' => true),

IN UploadController.php

$files=CUploadedFile::getInstances($model,'file');

IN view.php

<?php echo CHtml::activeFileField($model, "file[0]")?>
<?php echo CHtml::activeFileField($model, "file[1]")?>
0

#5 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 744
  • Joined: 02-February 09

Posted 21 January 2013 - 09:52 AM

View Postnakarin, on 03 June 2012 - 06:59 AM, said:

IN Upload.php

array('file', 'file', 'types'=>'zip','allowEmpty' => true),

IN UploadController.php

$files=CUploadedFile::getInstances($model,'file');

IN view.php

<?php echo CHtml::activeFileField($model, "file[0]")?>
<?php echo CHtml::activeFileField($model, "file[1]")?>



This uploads the files but does no validation upon either of the files selected. Not a good solution. The author should comment how to fix this obviously this code hasn't been tested before written in the book.
0

#6 User is offline   trance 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 26-February 13

Posted 25 May 2013 - 09:45 AM

I got same problem.

Do anyone have a solution for this ?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users