1
1
发生这种情况的原因是您没有请求EXTERNAL\u存储权限。 从android API level 23(marshmallow)开始,android权限框架(我不知道这是否是正确的术语)已经发生了变化。 在marshmallow之前,您只需在清单文件中声明权限。但在marshmallow上,android权限被分类为 Normal permissions 和 Dangerous permissions . 如果您使用的是普通权限,那么所有android版本上的情况都是一样的。但是 如果您使用的是危险权限,则必须请求用户在运行时授予该权限 . 在您的情况下,您正在上载一个图像,该图像需要READ\u EXTERNAL\u存储和WRITE\u EXTERNAL\u存储权限。这些被归类为危险权限。因此,在执行任何需要这些权限的操作之前,必须先请求这些权限。 但是您不必分别请求这两个权限,因为这些权限属于一个权限 permission group . 根据官方文件,
也就是说,如果您在一个权限组上声明了两个权限,那么您只需要请求其中一个权限。如果用户授予该权限组的权限,则系统将授予您声明的位于同一权限组中的所有权限。 以下是请求存储权限的代码
其他一切都差不多。(很抱歉我的英语很差) 有关权限请求的详细信息 here |
2
0
您好,请检查清单文件中的第一个权限,如(读取外部、写入外部和相机,如果使用),然后输入运行时权限代码,以获取比棉花糖更大的设备。并使用文件提供程序从SD卡获取图像Uri。 并将以下代码放入onActivityResult()。
希望有帮助。 |
3
0
将此添加到您的AndroidManifest。xml:
对于api 23+,请阅读本教程: |
Idhamsyah · 无法在Laravel 5.2中上载图像 6 年前 |
Walker Farrow · 在单个服务器上存储用户上传的图片的位置 6 年前 |
blastme · 从公用文件夹laravel打印图像时出现问题 6 年前 |
Parkolo11 · 在上传图像之前使用jquery预览图像 7 年前 |
laraib · 在服务器上上载加密图像 7 年前 |