当我上传一张图片时,如果它很大,当我想显示它时,我收到这条消息 403 Forbidden

when i upload a image if it be big i got this message 403 Forbidden when i want to show it

我的模特是这个

class Image (model.Model):     
    Image = models.ImageField(upload_to='pic_folder/', default='', help_text='')

我的表格是这样的

class Image(form.Form):
      Image = form.ImageField()

我的看法是这样

def Image(request):
   if request.method=="POST":
      form =Image(request.POST,request.FILES)
      if form.is_valid():
             cd =form.cleaned_data
             t = Image(Image=cd["Image"])
              t.save()
   else:
       form=Image()
       return render(request,"template.html",{'form':form}

模板

<form method="post" enctype="multipart/form-data">{%csrf_token%}
   <input type="file" name="Image" >
   <input type="submit" name="" valu="ok">
</form>

图片小点就好了 但如果它很大 我知道了

Nginx 禁止您上传文件,因为您的文件大小大于client_max_body_size。编辑你的 nginx 配置,添加 client_max_body_size。像下面这样更改它:

server {
    client_max_body_size 50M;

    //other lines...
}

permission denied 是由 nginx 引发的,请将 nginx 日志错误添加到您的问题中 nginx 不允许我保存超过 2 MB 的文件