1

I want to store a string that stores a file path "C:/myfile.txt".

I've tried initially with Django's FileField but that uploads the file to the server which it is not what I want.

Right now I am circumventing this by having a textfield and people just copy paste the file URL but I was trying to get it by using forms.FileInput() in order to choose the file, but then I only want to retrieve its path which I haven't been able to.

widgets = {'data': forms.DateInput(attrs={'id': 'datepicker'}),'fileloc': forms.FileInput() }

By doing I am able to have a Browse input on my form and allows me to select the file but it fails to validate the form. I need to convert the FileInput to string retrieving its File Path.

Has anyone encountered this before and has any idea how can I solve it?

myrahz
  • 31
  • 1
  • Where is the file path string being stored? Is it in a model? Can you provide more detail regarding what you are trying to do? Can you also show us your models, forms and view .py files. – death and gravity Mar 13 '17 at 12:31
  • I don't think you can do this by file input, and this is for security reasons. The browser will not give you the full path of the selected file. please refer to discussion here http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav – Gagik Sukiasyan Mar 13 '17 at 18:19
  • I will just stick with the copy pasta file path for that I guess. – myrahz Mar 14 '17 at 14:12

0 Answers0