Revoluzifer
Revoluzifer

Reputation: 323

Multiple uploads to different directories using FuelPHP

I'm trying to figure out how to deal with multiple uploads in FuelPHP. Basically this is an easy task, regarding the documentation.

My problem is: I've got two files per POST, one pdf and one jpg.

Now I want the jpg to be stored in another directory than the pdf.

Is there any possibility to do so which I might habe missed?

Thanks in advance!

Upvotes: 0

Views: 487

Answers (1)

Revoluzifer
Revoluzifer

Reputation: 323

Sorry for being stupid :D I really did miss the important note in the docs. So this is how I solved my problem:

Upload::process();
if(Upload::is_valid())
{
    $arr = Upload::get_files();
    //var_dump($arr);
    for ($i=0; $i < count($arr); $i++) 
    {
        if($arr[$i]['extension'] == 'pdf')
        {
            Upload::save($i, $catDir);
            $oldModel->catalogueFile = $arr[$i]['name'];
        }
        else if($arr[$i]['extension'] == 'jpg')
        {
            Upload::save($i, $thumbDir);
            $oldModel->catalogueImage = $arr[$i]['name'];
        }
    }
}

Upvotes: 2

Related Questions