Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:10:33+00:00 2026-06-04T00:10:33+00:00

Is this possible ? This is with a model CUploadedFile::getInstance($model,’newsimage’); $model->image->saveAs(image\path) but I don’t

  • 0

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.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:10:35+00:00Added an answer on June 4, 2026 at 12:10 am

    Assuming that “without model”=”without a db table”

    You Just make a UploadForm.php extending from CFormModel in your models directory

    class UploadForm extends CFormModel
    {
        public $upload_file;
    
        public function rules()
        {
            return array(
            array('upload_file', 'file', 'types'=>'jpg,jpeg,gif,png','maxSize'=>10*1024*1024),
            );
        }
    
        /**
         * Declares attribute labels.
         */
        public function attributeLabels()
        {
            return array(
                'upload_file'=>'Upload File',
            );
        }
    
    }
    

    and in your controller

    $model->upload_file=CUploadedFile::getInstance($model,'upload_file');
    $model->upload_file->saveAs("C:\myProject\images\".$model->upload_file->name)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible? Situation is that I want to store some XML in my
It this possible? How? (Maybe silly question, but I couldn't find answer :( )
I want to have a django model like this: class Model(models.Model): string = models.CharField()
Is it possible to create a join table without a model. I have a
I want to do something like this: # models.py class Model(models.Model): name_in_my_model = models.CharField(max_length=100)
So far, I don't think this is possible as I've been on it for
I am not sure if this is possible but here is my situation. Say
I know this works: <c:out value=${model.testhash['A']}/> but I need something like: <c:out value=${model.testhash[${model.testkey}]}/> Is
Is this possible!!?!?!?!? I'm trying to make a set of classes that model a
Is this possible with Rails+Mongoid: Model.update_all(position=position-1)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.