gpt4 book ai didi

javascript - 限制用户只能上传指定的文件格式

转载 作者:行者123 更新时间:2023-12-03 08:49:44 24 4
gpt4 key购买 nike

我设法让用户上传pdf、doc和docx格式的文件。但是,用户现在可以上传任何格式的文件。这并不能阻止他们。他们上传任何格式的文件,但程序不会将它们存储在上传路径中。我想限制他们只能上传我表单中的这些格式,如果格式不同,程序会阻止他们。我把我的代码作为额外引用:

 $config['upload_path'] = './media/resumes/';


$config['allowed_types'] = 'pdf|doc|docx';
$config['max_size'] = '100000';

$this->load->library('upload', $config);
$this->upload->initialize($config);
$this->upload->do_upload("myfile");

$file = $this->upload->data();
$filename=$file['file_name'];

期待您的答复

最佳答案

您可以在附加文件时使用它:

        <input type="file" name="userfile" id="fileAttachmentID" accept=".pdf,.doc,.docx">

关于javascript - 限制用户只能上传指定的文件格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32739561/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com