My form looks like this
def handle(self,filefield_data):
""" Upload the file data, in chunks, to the SHP_UPLOAD_DIR specified in settings.py.
"""
# ensure the upload directory exists
if not os.path.exists(settings.SHP_UPLOAD_DIR):
os.makedirs(settings.SHP_UPLOAD_DIR)
# contruct the full filepath and filename
downloaded_file = os.path.normpath(os.path.join(settings.SHP_UPLOAD_DIR, filefield_data.name))
The error I get is SHP_UPLOAD_DIR is not declared in settings.py. I understand that I need to declare the directory in settings.py , but how do I declare it in settings.py and do I need to also create a SHP_UPLOAD_DIR . If I have to create such a directory , what should be its path ?
You need to add a line to your settings.py file:
You will need to create this directory yourself*, and it can be anywhere there is space for the files to live. The only requirement is that the user your website is running as has to be able to write to it. Your best bet is to put it somewhere and then see if you get an error when uploading a file.