python - Flask upload cannot find directory in server -
i have problem flask upload in local machine code working when upload code server using apache show error
ioerror: [errno 2] no such file or directory: u'app/static/avatars/khuon.s.png'
code :
allowed_extensions = set(['png', 'jpg', 'jpeg', 'gif']) app.config['upload_folder'] = 'app/static/avatars' app.config['max_content_length'] = 1 * 600 * 600 def allowed_file(filename): return '.' in filename , filename.rsplit('.', 1)[1] in allowed_extensions @app.route('/user/profile', methods=['get', 'post']) def upload_profile(): if request.method == 'post': file = request.files['file'] if file , allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(app.config['upload_folder'], filename)) else: flash("file extension not allow.") return redirect(url_for('upload_profile', upload='error')) return render_template("profile.html")
ok, in upload.py like
import os absolute_path = os.path.abspath(upload_folder+file_name)
os.path.abspath returns absolute path given relative path.