The input is not a valid Base-64 string as it contains a non-base64 character?

后端 未结 3 1157
深忆病人
深忆病人 2021-01-01 13:27

I have a form where a user can upload a file to the sites download section. However when the form is submitted I get this error, without the request ever making it to the ac

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-01 14:21

    Alex, you are partially correct with your assessment. The reason why it fails when you have a property of the same name on your model as the name of the input object on the form is due to the fact that the DataType of the matchingly-named property on your model is not System.Web.HttpPostedFileWrapper which is the datatype that the binary-binder will attempt to perform a bind to.

    Excluding your property by using the Bind attribute and then extracting the file from the Request.Files collection as you demonstrated may work, but it may be more elegant to let the binder do its thing (provided that the data type is matching as I mentioned above) and then you can simply access the file directly from the property of your model

提交回复
热议问题