问题
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