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 6329967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:46:36+00:00 2026-05-24T17:46:36+00:00

For a file upload I have the action below. This creates a dir with

  • 0

For a file upload I have the action below. This creates a dir with the currentDate as I have defined in my model and a uploads my file renaming it to the ImageId.

The problem is that the directory and Image are both created within the same dir. I need the Image to be placed in the newly created directory though. Any ideas?

$model->attributes=$_POST['ImageUpload'];
$model->image=CUploadedFile::getInstance($model,'image');
if($model->save())
{
    exec("mkdir -p " . Yii::app()->basePath . "/../images/uploads/$data->currentDate");
    $model->image->saveAs(Yii::app()->getBasePath()."/../images/uploads/$data->currentDate/$model->ImageId");
    $this->redirect(array('view', 'id' => $model->ImageId));
}
  • 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-05-24T17:46:37+00:00Added an answer on May 24, 2026 at 5:46 pm

    Are you sure you have anything in $model->ImageId?

    I’m using roughly the same code:

    if (!file_exists ($fileSavePath))
        mkdir ($fileSavePath, 0, true);
    
    $fileSavePath .= $form->my_file->name;
    $form->my_file->saveAs ($fileSavePath);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this form to upload an xml file to server, I am using
i have problem on my php file upload script , i am trying to
I have created a function to upload a file using this library as follows:
I have a form to upload image like below <form name=sample enctype=multipart/form-data action=index.php method=post
I have a file upload form that is being posted back to a servlet
I have a HTML file upload field from which I'm reading the file name
I have a file upload control <input id=File1 type=file /> in my page... How
I have implemented a simple file upload-download mechanism. When a user clicks a file
I have a form that excepts a file upload in ASP.NET. I need to
I have a web application that needs to take a file upload from the

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.