Hi! I use XUploadFile for upload photo to my site and want it to store image url in mysql, but i don’t know to how do this. Can anyone help me with this.

Buddy, I haven’t used Xupload. But this a generic method I use to upload the file and save url in my database.

Your view file

<?php $form=$this->beginWidget('CActiveForm', array(




)); ?>

<div class="row">

		<?php echo $form->labelEx($model,'image'); ?>

		<?php echo $form->fileField($model,'image'); ?>

		<?php echo $form->error($model,'image'); ?>


Then in your controller file. In the create action function. In addition, create a folder called images at /protected/images. All your files will be stored here.



			$model->attributes=$_POST[' Whateva value u have here'];



			//adding image code



                        $fecha = date('YmdHms');


                        $model->image = $fecha.'_'.$model->image;   


			//end image code