【发布时间】:2017-12-10 09:49:13
【问题描述】:
我正在尝试提供允许的扩展名,所以我确实尝试了这段代码,但我得到了错误提示
未定义索引:文件[]
$ly_formname = 'files[]';
$file_type = $_FILES[$ly_formname]['type']; //returns the mimetype
$allowed = array("image/jpeg", "image/gif", "application/pdf");
if(!in_array($file_type, $allowed)) {
$error_message = 'Only jpg, gif, and pdf files are allowed.';
$error = 'yes';
}
我更改了我的变量名,但仍然收到消息错误
yii框架中的表单名是file[]
public function run()
{
return Html::input('file', 'files[]', null, $this->getOptions());
}
我的输入代码是:
<input type="file" id="contentFormFilesGallery" name="files[]"
multiple="multiple" title="Upload file" accept="image/*" data-upload-url=""
data-upload-drop-zone="#contentFormBody" data-upload-
progress="#contentFormFiles_progress" data-upload-
preview="#contentFormFiles_preview" data-upload-form="" data-upload-single=""
data-upload-submit-name="fileList[]" data-upload-hide-in-stream="" data-php-max-
file-uploads="20" data-php-max-file-uploads-message="Sorry, you can only upload
up to 20 files at once." data-max-number-of-files="50" data-max-number-of-files-
message="This upload field only allows a maximum of 50 files." data-ui-
widget="file.Upload" data-ui-init="1" style="display:none">
【问题讨论】: