简体   繁体   中英

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();
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM