mpalencia
mpalencia

Reputation: 6037

Fuelphp Upload 2 kinds of file on the same controller or model

I am using Fuelphp Upload Class for along time. But this is the first time I am going to save 2 types of file on the same controller. First file is an image, the second is a CSV file. However I notice it doesn't work for some reason (The image is saved correctly but the csv is not saving). There is nothing wrong with the file i am uploading. I just don't know how to save 2 kinds of file on same controller or model. Any hints? Thanks in advance! Here is the generic view of my code

$image_config = array('path' => '/mypath/forimage',
                'randomize' => true,
                'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'),
);

Upload::process($image_config);

if (Upload::is_valid())
{
    //save image
    Upload::save();
}


$csv_config = array('path' => '/mypath/forcsv',
                'randomize' => true,
                'ext_whitelist' => array('csv', 'txt'),
);

Upload::process($csv_config);

if (Upload::is_valid())
{
   //save csv
   Upload::save();
}

Upvotes: 1

Views: 110

Answers (1)

kenjis
kenjis

Reputation: 664

You can call Upload::process() only one time.

The process method processes the information about all uploaded files
http://fuelphp.com/docs/classes/upload/usage.html#/method_process

And Upload::save() also save all validated uploaded files.

Upvotes: 1

Related Questions