title: i am trying to upload image in django but it gives me MultiValueDictKeyError at /index 'myfile'
body: <p>I tried to insert image into sqlite but it didn't worked with it gives me error evertime
  this is my code</p>
  <pre><code>def index(request):
      dbname = 'user1'
      cursor = connections[dbname].cursor()
      if request.POST.get('done'):
          cursor.execute('insert into images values(%s)', [request.FILES['myfile']])
      return render(request, 'index.html')
  </code></pre>
  <p>and this is the error</p>
  <pre><code>MultiValueDictKeyError at /index
  'myfile'
  Request Method: POST
  Request URL:    http://127.0.0.1:8000/index
  Django Version: 3.2
  Exception Type: MultiValueDictKeyError
  Exception Value:    
  'myfile'
  Exception Location: D:\omar\pythonProject\venv\lib\site-packages\django\utils\datastructures.py, line 78, in __getitem__
  Python Executable:  D:\omar\pythonProject\venv\Scripts\python.exe
  Python Version: 3.9.2
  Python Path:    
  ['D:\\omar\\pythonProject',
   'C:\\Users\\taha_lab\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip',
   'C:\\Users\\taha_lab\\AppData\\Local\\Programs\\Python\\Python39\\DLLs',
   'C:\\Users\\taha_lab\\AppData\\Local\\Programs\\Python\\Python39\\lib',
   'C:\\Users\\taha_lab\\AppData\\Local\\Programs\\Python\\Python39',
   'D:\\omar\\pythonProject\\venv',
   'D:\\omar\\pythonProject\\venv\\lib\\site-packages']
  Server time:    Mon, 28 Jun 2021 00:18:52 +0000
  Traceback Switch to copy-and-paste view
  D:\omar\pythonProject\venv\lib\site-packages\django\utils\datastructures.py, line 76, in __getitem__
              list_ = super().__getitem__(key) …
  ▶ Local vars
  During handling of the above exception ('myfile'), another exception occurred:
  D:\omar\pythonProject\venv\lib\site-packages\django\core\handlers\exception.py, line 47, in inner
                  response = get_response(request) …
  ▶ Local vars
  D:\omar\pythonProject\venv\lib\site-packages\django\core\handlers\base.py, line 181, in _get_response
                  response = wrapped_callback(request, *callback_args, **callback_kwargs) …
  ▶ Local vars
  D:\omar\pythonProject\Dhb\views.py, line 5951, in index
          cursor.execute('insert into images values(%s)', [request.FILES['myfile']]) …
  ▶ Local vars
  D:\omar\pythonProject\venv\lib\site-packages\django\utils\datastructures.py, line 78, in __getitem__
              raise MultiValueDictKeyError(key) 
  </code></pre>
  <p>I tried to insert image into sqlite but it didn't worked with it gives me error evertime</p>