I am trying to upload a CSV file using FLASK using this below code and I am trying to save the session of that file so that I can use later.
if request.method=="POST":
text=request.files['file']
text_f=secure_filename(text.filename)
text.save(os.path.join("",text_f))
path=os.path.abspath(os.path.join("",text_f))
with open(path) as tickets:
ticket=pd.read_csv(tickets)
tic_body=ticket['body']
#session['tic_body']=tic_body
Below is the HTML Code.
<input type="file" class="form-control" id="images" name="file" multiple/>
<input type="submit" class="btn btn-labeled btn-primary" value="stop">
Using this I am trying to upload a file I am receiving the below error.
werkzeug.exceptions.HTTPException.wrap..newcls: 400 Bad Request: KeyError: 'file'
Note: At times ,when I am not using the session I was able to load the file without any error.