如何使用 MeioUpload Behaviour 上传任何类型的文件,而不仅仅是图像

发布于 2024-11-10 04:39:46 字数 1121 浏览 7 评论 0原文

我想使用 MeioUpload Behaviour 上传任何类型的文档(我想要每个扩展才能被接受)。我已经看过这个问题,但它对我不起作用,出于某种奇怪的原因我只能上传其他类型文件的图像和 pdf 文件 当我尝试提交表单时出现此错误:“无法保存该帖子。请重试。”

编辑:嗯,看起来我终于能够上传除图像之外的其他类型的文件,我必须编写选项'allowedMime'和'allowedExt ' 采用驼峰命名法(在文档中,他们使用下划线版本 'allowed_mime'、'allowed_ext' 我不知道为什么:( ),但我还没有没有去过能够上传 .zip 文件,最重要的是我仍然不知道如何告诉行为接受任何内容

var $actsAs = array(
    'MeioUpload' => array(
        'link_referencia' => array(
            'dir' => 'files{DS}uploads',
            'create_directory' => true,
            'allowedMime' => array('application/pdf', 'application/msword', 'application/vnd.ms-powerpoint', 'application/vnd.ms-excel', 'application/rtf', 'application/zip'),
            'allowedExt' => array('.pdf', '.doc', '.ppt', '.xls', '.rtf', '.zip'),
            'default' => false,
         )
       )
    );

提前致谢

I would like to use the MeioUpload Behavior for uploading any kind of documents(I want every extension to be accepted). I've already seen this question , but it didn't work for me, for some strange reason I can only upload image and pdf files for the other types of files I get this error when I attempt to submit the form : "The post could not be saved. Please, try again."

Edit: Well, it looks like I was finally able to upload other kind of files apart from images,I had to write the options 'allowedMime' and 'allowedExt' in camelCase (in the documentation they use the underscore version 'allowed_mime', 'allowed_ext' I don't know why:( ), but I haven't been able to upload .zip files and most importantly I still don't know how to tell the behaviour to accept anything

var $actsAs = array(
    'MeioUpload' => array(
        'link_referencia' => array(
            'dir' => 'files{DS}uploads',
            'create_directory' => true,
            'allowedMime' => array('application/pdf', 'application/msword', 'application/vnd.ms-powerpoint', 'application/vnd.ms-excel', 'application/rtf', 'application/zip'),
            'allowedExt' => array('.pdf', '.doc', '.ppt', '.xls', '.rtf', '.zip'),
            'default' => false,
         )
       )
    );

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囚你心 2024-11-17 04:39:46

它可以用于任何东西,因此它被称为 meioUpload 而不是 meioImage

只需在初始化行为时设置允许的文件扩展名和 mime 类型即可。

步骤 4 有一个示例 http://www.meiocodigo.com/projects/meioupload/

It can be use for anything, hence it's called meioUpload and not meioImage

Just set the allowed file extensions and mime types when you initialiave the behavior.

Step 4 has an example http://www.meiocodigo.com/projects/meioupload/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文