Take the 2-minute tour ×

I am absolutely new to programming. I have chosen Django to start, and I am learning through tutorials and pages like this. What I am trying to do is this: I have a .txt file in my root folder, and when I run a particular web page, I take information from that file and display some stuff. The problem is that I need that the users can upload a .txt from their computers, and that this file replaces the file in my root folder. So, that it is called for example data.txt and stored, and that the page refreshes (like F5, for now) so that the information shown is taken from that new file. Can anybody tell me how to do this, explained step by step 'for Dummies'? If possible, I would like to do it just in JavaScript (not Python). I don't need multiple uploads, and it is not necessary that the upload involves AJAX or anything like that, despite I know that it is nicer. Thank you very much!

share|improve this question
did you google "javascript file upload"? –  lbstr Jul 10 '12 at 23:07
an explanation for my question -- there are a million tutorials and plugins out there for uploading. This site is great for when you try something and get stuck, but not so great for asking how to do something with no effort shown –  lbstr Jul 10 '12 at 23:08
You can't do an upload in pure client-side JavaScript, you need something on the server side to process the file (python, php, nodejs, ect) –  Austin Jul 10 '12 at 23:09
Yes, I looked for it and didn't find it for Python. Or didn't understand it. –  andresmechali Jul 10 '12 at 23:41
add comment

2 Answers

first, javascript cannot upload a file from the client's computer, otherwise I would be able to send you to a website that would steal all of the files on your computer.

second, all you need to upload a file is an html form, where the user can select a file, then submit the form, thus uploading it to your server. a server side script is then needed to move the uploaded file to wherever you want it.

third, you should realllly be careful about allowing uploads to your server, as this can be a gaping vector for malware to be installed on your server if not done correctly.

fourth, since you are using django as your server side language, you will probably just want to google "uploading files using django". Here is the django documentation on how to do file uploads:


share|improve this answer
add comment

It seems like you wouldn't need a javascript solution to do that and using basic Django could work. However if you keep interested in manipulating files with Javascript there's an explanation on how to do that at:

How to preprocess a local CSV file before uploading to a server?

share|improve this answer
add comment

Your Answer


