Is this possible ? This is with a model
CUploadedFile::getInstance($model,'newsimage');
$model->image->saveAs("image\path")
but I don't want to create a model just so i can save my image.
What I actualy need this for is ... well I am trying to make the "Upload image" function of CKEditor to work, but I need a script for the image saving.
When I click the "Upload image" button i just call an action and from there I have access to the picture I have selected, using $_FILES
, but I can't seem to save the file to a target directory.
Is it possible to save the file to a target path ("C:\myProject\images" for example) and not use a model ?
EDIT :
Here is a solution i found a little bit later
The file i upload is in $_FILES['upload']
so ..
$temp = CUploadedFile::getInstanceByName("upload"); // gets me the file into this variable ( i gues this wont work for multiple files at the same time )
$temp->saveAs("D:/games/" . $temp->name); // full name , including the filename too.
Assuming that "without model"="without a db table"
You Just make a UploadForm.php extending from CFormModel in your models directory
and in your controller