简体   繁体   English

Fuelphp在同一控制器或模型上上传2种文件

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

I am using Fuelphp Upload Class for along time. 我一直在使用Fuelphp Upload Class。 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. 第一个文件是图像,第二个文件是CSV文件。 However I notice it doesn't work for some reason (The image is saved correctly but the csv is not saving). 但是我注意到由于某些原因它不起作用(图像保存正确,但csv没有保存)。 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. 您只能调用一次Upload::process()

The process method processes the information about all uploaded files 处理方法处理有关所有上载文件的信息
http://fuelphp.com/docs/classes/upload/usage.html#/method_process http://fuelphp.com/docs/classes/upload/usage.html#/method_process

And Upload::save() also save all validated uploaded files. 并且Upload::save()还会保存所有经过验证的上传文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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