-1

home.html

<form action="" method="POST" enctype="multipart/form-data">
        {% csrf_token %}
        <input type="file" name = 'img' >
        <button type="submit"> Post On Facebook </button>
</form>

views.py

def home(request):
    if request.method == 'POST':
          # get the image absolute location 
        
    return render(request,'home.html')

I want the file path, so that I can upload the file on facebook using GraphAPI.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
  • https://stackoverflow.com/questions/42544523/how-do-i-get-a-files-absolute-path-after-being-uploaded-in-django/42545154 – Hamed Jul 08 '21 at 17:24
  • you should find this in any tutorial or in official documentation. So better find some tutorial and you will get solutions much faster than asking on Stackoverflow. – furas Jul 08 '21 at 18:58

1 Answers1

0

You need to set your upload path in your models file. Then you can save it to that particular path in your view function.

For details refer - https://simpleisbetterthancomplex.com/tutorial/2016/08/01/how-to-upload-files-with-django.html

cshelly
  • 535
  • 3
  • 10