0

I'm working on a django app (web). I have my awesome page with a form on it. I want to let the user select a file on their local machine via the nice file upload button that you get for the <input type="file">.

I don't care however about the file content. I only care about its absolute path, so I'd like to get that into a text field (or whatever) and submit it from my html form.

My other option (unacceptable actually) would be to let the users write the filepath in the input field by themselves... but that's not cool at all.

Does this sound doable?

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
vlad-ardelean
  • 7,480
  • 15
  • 80
  • 124
  • Here on StackOverflow, we prefer to fix you problems. What we don't want to do is develop something from scratch just for you. (But, you know... If you're willing to pay we would pull some strings ;) ....) –  Jun 13 '15 at 09:00
  • 2
    What use is an absolute path on the client's machine, though? – Daniel Roseman Jun 13 '15 at 09:02
  • well thanks for the input, but i'd really like to do this thing, and I'm not a frontend guy at all.... a little help would be apreciated, because I seriously don't want to go read 2 books just to do this. Don't know if you've been in my situation :) – vlad-ardelean Jun 13 '15 at 09:03
  • @vlad-ardelean You can't do that in a web browser, it's a security risk. – CodingIntrigue Jun 13 '15 at 09:06
  • @DanielRoseman I'm developing this app called `django-localsrv`. Its use case is: you have a server that serves whatever files/ strings you want, with whatever headers you want, to your own machine. I use it for testing, we have problems a lot of times with "just serving something quick BUT with a few custom headers", and you'd see how installing and configuring an apache instance or whatever would be overkill. – vlad-ardelean Jun 13 '15 at 09:06

1 Answers1

1

Most modern browsers don't give access to filesystem. And when you choose to upload a file, it replace the real path.
Try: <input type="file" onchange="alert(this.value)"/>

Will give you C:\fakepath\Myfile.txt

Cyrbil
  • 6,341
  • 1
  • 24
  • 40