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: 222
  • 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: 751
  • 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: 33
  • Joined: 26-February 13

Posted 25 May 2013 - 09:45 AM

I got same problem.

Do anyone have a solution for this ?
0

#7 User is offline   haven 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 28-May 12

Posted 26 August 2014 - 12:05 AM

hello my first response to the forum, always read he never contributes, c'mon

I to using a multiupload with multiple files

so do not know if it actually looked rather more follows the MVC pattern code



#Model

public function rules()
	{

		return array(
		...
	array('picture', 'pictureRule'),
	
	
	.. );
	}
	
	
	public function pictureRule()

			 {
				 $picture_test=CUploadedFile::getInstancesByName('picture');

				 if(empty($picture_test)) 
				 {
					  $this->addError('pictureRule', 'Error not file blank!');
				 	  return false;
				 }else{
					 return true;

				 }

		     }
		
#Controler


*remember to put that part of the instance file after validation

* i use  [url="http://www.yiiframework.com/extension/euploadedimage/"]EUploadImage[/url] extension for good make thumbs
public function actionCreate()
{


$model=new Produts;


if(isset($_POST['Produts']))
{
	
$model->attributes=$_POST['Produts'];
if($model->validate()){   

$picture = EUploadedImage::getInstancesByName('picture');



Thanks
0

#8 User is offline   Rohit Suthar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 155
  • Joined: 12-May 14
  • Location:Mumbai, India

Posted 16 September 2014 - 12:21 AM

Try this -

array('imageList', 'file', 'types'=>'jpg, gif, png', 'allowEmpty' => true, 'maxFiles' => 10)

Thanks & regards,

ROHIT SUTHAR,
Mumbai(India)

Follow me - @rohisuthar

www.yiiframework.us



Don't be shellfish to click +1 button
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