I’ve looked through the posts and haven’t found a solution or even someone else with this same problem. That means to me that it’s probably something really simple that I’m overlooking
Whenever I try to upload an image, I keep getting the following error:
move_uploaded_file(/BuilderApp/public_html/images/BirchwoodIFP.gif) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: No such file or directory
But, I know that directory exists because that’s where all my images are located and they appear in the application.
Here is my controller:
public function actionCreate()
{
$model=new Floorplan;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Floorplan']))
{
$model->attributes=$_POST['Floorplan'];
$model->floorplanFile=CUploadedFile::getInstance($model,'floorplanFile');
$model->floorplanURL = '/'.$model->floorplanFile;
if($model->save())
{
$model->floorplanFile->saveAs(Yii::getPathOfAlias('images').'/'.$model->floorplanFile);
$this->redirect(array('view','id'=>$model->floorplanID));
}
}
$this->render('create',array(
'model'=>$model,
));
}
My _form:
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'floorplan-form',
'enableAjaxValidation'=>false,
'htmlOptions'=>array('enctype'=>'multipart/form-data'),
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name',array('size'=>20,'maxlength'=>20)); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'planID'); ?>
<?php echo $form->textField($model,'planID',array('size'=>10,'maxlength'=>10)); ?>
<?php echo $form->error($model,'planID'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'floorplanURL'); ?>
<?php echo $form->fileField($model,'floorplanFile'); ?>
<?php echo $form->error($model,'floorplanFile'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'deleted'); ?>
<?php echo $form->textField($model,'deleted',array('size'=>1,'maxlength'=>1)); ?>
<?php echo $form->error($model,'deleted'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Any help would be greatly appreciated.
Thanks in advance.