So I have everything linked together. I've gone through every post on here related to flask and photo uploads and have tried all of them but nothing seems to be fixing me issues, it seems that the photo url does not get saved to the page so when i load the page from route the photo does not appear, I inspect elemented the page and could not find a image url located either. Here is my route
@bp.route('/edit/<path:url>/', methods=['GET', 'POST'])@protectdef edit(url): page = current_wiki.get(url) form = EditorForm(obj=page) if form.validate_on_submit(): if not page: page = current_wiki.get_bare(url) form.populate_obj(page) if 'file' in request.files: file = request.files['file'] if file.filename != '': filename = secure_filename(file.filename) file.save(os.path.join(CONTENT_DIR, filename)) page.save() flash('"%s" was saved.' % page.title, 'success') return redirect(url_for('wiki.display', url=url)) return render_template('editor.html', form=form, page=page)as seen it saves the photo file to my content_dir which works the photo does get saved there I can see that it does. It still does not appear on my page though. here is the relevant code to that
{% extends "base.html" %}{% block title %} {{ page.title }}{% endblock title %}{% block content %}<div id="confirmDelete" class="modal hide fade" aria-hidden="true"><div class="modal-header"><h3>Are you sure?</h3></div><div class="modal-body"><p>Are you sure you want to delete {{ page.title }}? This cannot be undone.</p></div><div class="modal-footer"><a href="#" class="btn" data-dismiss="modal" aria-hidden="true">No</a><a href="{{ url_for('wiki.delete', url=page.url) }}" class="btn btn-danger">Yes, delete.</a></div></div><!-- Display uploaded image --> {% if page.image_url %}<img src="{{ page.image_url }}" alt="Uploaded Image"> {% endif %}<!-- Display other page content --><h1>{{ page.title }}</h1><p>{{ page.body }}</p>{% endblock content %}I also added to my forms the ability to save photos. Not sure where I am going wrong here? I know that page is called from base.html so maybe somehow the photo url isn't being saved to my page? But I dont know how that would be since this is how my editor form is set up
<form method="post" class="form" enctype="multipart/form-data"> {{ form.hidden_tag() }} {{ input(form.title, placeholder="Title", class="span7", autocomplete="off") }} {{ input(form.body, placeholder="Markdown", class="span7", rows="20") }} {{ input(form.tags, placeholder="Tags (comma separated)", class="span7", autocomplete="off") }}<input type='file' name='file' onchange="readURL(this);" /><div class="form-actions"><div class="pull-left"><a class="btn" href="#preview" id="previewbtn">Preview</a></div><div class="pull-right"><a class="btn" href="{{ url_for('wiki.display', url=page.url) }}">Cancel</a><button class="btn btn-success" type="submit">Save</button></div></div></form>I tried to add a photo option to my flask program but the photo does not appear on page, it saves to the folder but doesn't appear. I've tried linking it a few ways but it does not some to save to page