Multiple uploads to different directories using FuelPHP

空扰寡人 提交于 2019-12-11 17:57:36

问题


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!


回答1:


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'];
        }
    }
}


来源:https://stackoverflow.com/questions/13584265/multiple-uploads-to-different-directories-using-fuelphp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!