Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii-如何定义;浏览文件类型“;与我们所需的文件类型相同吗?_Php_Html_Yii - Fatal编程技术网

Php Yii-如何定义;浏览文件类型“;与我们所需的文件类型相同吗?

Php Yii-如何定义;浏览文件类型“;与我们所需的文件类型相同吗?,php,html,yii,Php,Html,Yii,我的web应用程序中有一个上传系统,我已经定义了文件类型规则,允许在/models/File.php中使用:.pdf、.xls、.xlsx、.doc、.docx、.ppt和.pptx 这是我的密码: public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array(

我的web应用程序中有一个上传系统,我已经定义了文件类型规则,允许在/models/File.php中使用:.pdf、.xls、.xlsx、.doc、.docx、.ppt和.pptx 这是我的密码:

public function rules()
{
    // NOTE: you should only define rules for those attributes that
    // will receive user inputs.
    return array(
        array('nama_file, id_kategori', 'required'),
        array('nama_file', 'length', 'max'=>100),
        array('nama_file', 'file', 'types'=>'pdf, xls, xslx, doc, docx, ppt, pptx, ppsx', 'maxSize'=>50 * 1024 * 1024, 'tooLarge'=>'File tidak boleh lebih dari 50 Megabytes'),
        array('id_user, id_kategori', 'length', 'max'=>11),
        array('deskripsi', 'safe'),
        // The following rule is used by search().
        // Please remove those attributes that should not be searched.
        array('id_file, nama_file, deskripsi, id_user, id_kategori, tgl_post', 'safe', 'on'=>'search'),
    );
}
我希望在我的web应用程序中上载文件时,“浏览”对话框显示我定义的文件类型:


我该怎么做?非常感谢。

在文件字段中设置我的类型将有助于筛选用户可以选择的文件

<div class="row">
    <?= $form->labelEx($model, 'nama_file'); ?>
    <?= $form->fileField($model, 'nama_file', array('accept' => 
            'application/ms*,application/vnd*,application/pdf')); ?>
    <?= $form->error($model, 'nama_file'); ?>
</div>


但是,Google Chrome不会显示文件类型,而是显示“自定义文件”。您无法更改此实现。

嘿,谢谢您的回答,但它仍然不起作用。我使用yiibooster
filefieldRow1
。你能帮我个忙吗?很抱歉我的问题重复了,但我不知道怎么做,我刚接触Yii。