This is my upload function but every time I go to addclothes
route and adding image into the form then I got this error:
I know is my path problem but I don't know how to put the file in the base directory
@app.route('/addclothes', methods=["POST","GET"])
def addclothes():
if request.method == 'POST':
if 'file' not in request.files:
flash('No file part')
return redirect(request.url)
file = request.files['file']
if file.filename == '':
flash('No selected file')
return redirect(request.url)
if file :
filename = secure_filename(file.filename)
file.save(os.path.join('/static/img/',filename))
new_clothes = Clothes(clothesname=clothesname,image=image,price=price,isSuperUser=False)
db.session.add(new_clother)
db.session.commit()
return redirect(url_for('addclothes'))
return render_template('addclothes.html')
This is my file structure:
I want to add it to base directory