How Make Dnamic One To Many Multiupload File?

I have 2 tables like this :

table artist

id int Primary Key,

artistname;

table song

id in Primary Key,

artist_id int Foreign Key,

filesong varchar;

I write in songcontroller like this :




public function actionCreate()

	{

		$model=new Song;


		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);


		if(isset($_POST['Song']))

		{

			$model->attributes=$_POST['Song'];

			$uploadedFile=CUploadedFile::getInstance($model,'filesong');

			$fileName = "{$uploadedFile}";  //  file name

            $model->filesong = $fileName;

			if($model->save())

			if(isset($fileName) && count($fileName) > 0)

					{

						foreach ($fileName as $i=>$ii)

						{

							if ($ii->saveAs(Yii::getPathOfAlias('webroot').'/storage/'.$ii->name))

								{

									$file_add = new Song();

									$file_add->filesong = $ii->name;

									

									$file_add->save();

									}

							else

									$file_add = new Song();

									$file_add->filesong = $ii->name;

									

									$file_add->save();

						if($model->save())

								{

						$this->redirect(array(‘view’,'id'=>$model->id));


									}

						}

					}

		}

	

		$this->render('create',array(

			'model'=>$model,

		));

	}



it doesn’t work at all … ;(

How to use CMultiFileUpload ?so I can insert table song with dynamic upload …help me, please

Hey Yiijco,

i added a multiupload

function in a previous project of mine.

I used this extension:

http://www.yiiframework.com/extension/xupload

it did the job for me.

for ie7/ie8

i ended up using swfupload (flash based plugin)

I hope this will help you in the correct direction.

thank you …and I follow this extension but I have error like this "SyntaxError: JSON.parse: unexpected character"

so …what should I do? Can you give any example controller for this xupload…please help me

thanks in advance

PS: sorry with my English