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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:10:36+00:00 2026-06-14T23:10:36+00:00

I am adapting StationWagon (FuelPHP app) and so far it’s working really well. I

  • 0

I am adapting StationWagon (FuelPHP app) and so far it’s working really well.

I have adapted it (with some help) to allow multiple images to be uploaded to the server. This is also working great.

However, I am thinking it would make more sense if I had 2 Tables: 1) Articles and 2) ArticleImages. I would use a Foreign Key to associate the Images with the Article. So when publishing an article it would add the article data to ‘Articles’ table and move each image to a new row in ‘ArticleImages’.

So ultimately my ‘ArticleImages’ table could be:

ID | ImageURL | ArticleID

Portion of my ‘articles.php‘ controller:

<?php       

    public function action_add()
    {
    $val = Model_Article::validate('add_article'); //<-- maybe its just me but i never saw any similar to this in fuelphp sorry about this if im wrong

    // if your form validation is okay than continue with everyhing else
    if ($val->run())
    {
        $article = Model_Article::forge();
        // Custom configuration for this upload
        $config = array(
            'path' => DOCROOT.DS.'images',
            'randomize' => true,
            'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'),
        );

        Upload::process($config);

        // if a valid file is passed than the function will save, or if its not empty
        if (Upload::is_valid())
        {
            // save them according to the config
            Upload::save();

           //if you want to save to tha database lets grab the file name
            $value = Upload::get_files();  

            foreach($value as $files) {
               print_r($files); 
            }
            $article->filename = $value[0]['saved_as'];
         } 

        $status = (Input::post('save_draft') ? 0 : 1);

        if ( ! $val->input('category_id'))
        {
            $category_id = null;
        }
        else
        {
            $category_id = $val->validated('category_id');
        }

             $article->user_id = $this->user_id;
             $article->category_id = $category_id;
             $article->title = $val->validated('title');
             $article->body = $val->validated('body');
             $article->published = $status;


        if ($article->save())
        {
            Session::set_flash('success', 'Article successfully added.');
        }
        else
        {
            Session::set_flash('error', 'Something went wrong, '.
                'please try again!');
        }

        Response::redirect('articles/add');
    }

    $this->template->title = 'Add Article';
    $this->template->content = View::forge('articles/add')
        ->set('categories', Model_Category::find('all'), false)
        ->set('val', Validation::instance('add_article'), false);
    }

/* End of file articles.php */
  • 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-14T23:10:38+00:00Added an answer on June 14, 2026 at 11:10 pm

    So when i made the code for you back a few days a go you only requested, one file input.

    And no offense but you are doing it all wrong…

        foreach($value as $files) {
          print_r($files); 
        }
     $article->filename = $value[0]['saved_as'];
    

    should be

    foreach($value as $files) {
               $articleimg = Model_Articleimages::forge();
               $articleimg->image_row_name = $files['saved_as']
            }
    

    To get you to understand

    what you did here, $value = Upload::get_files(); yes this gets all the elements but since you need to loop trouh the elements you dont need it

    Second

    this $value[0]['saved_as'] only grabs the first image name, just the first one, and since you are in a loop now you need to refer to the $files variable as i shown you in the above example, just an example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working through the tutorial adapting it to a project I want
ok so i have an array adapted listview (the array adapting is done in
Didn't have this issue at all until I began adapting my app for iOS
I am looking for some help on adapting the following LINQ query to return
I've been working on adapting a CS app to a different app. In my
I've been working on adapting an iPhone app to iPad. Due to a number
I'm adapting an old WebOS app to android and I'm using phonegap for nearly
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
I'm working on adapting a jQuery slider that originally had 10 thumbnails. I only
So, I am adapting some code I found online to suit my needs. However,

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.