title: Flask url_for incorrectly links to static pages outside of templates
body: <p>I'm currently in the process of moving all of my static files to S3, as well as allowing some image uploads to my site. In general this is going fantastically. I got all of my existing css and js files up to S3 with no hassle, however I'm having some trouble with uploading images and saving them to S3.</p>
  
  <p>Specifically this is how I'm handling file uploads within my view:</p>
  
  <pre><code>image_file = request.files["imageurl"]
  if image_file and allowed_file(image_file.filename):
      fn = "products/%s" % secure_filename(image_title + "." + image_file.filename.split(".")[-1])
      image_file.save(url_for('static', filename=fn))
  else:
      response = app.make_response(render_template(
          'admin/newImage.html',
          title=title,
          error="That Image file is invalid.")
      )
      return response
  </code></pre>
  
  <p>Which is all wrapping in a POST request handler. The problem here is that the <code>url_for('static')</code> fails to link to the correct path, and so I get an <code>IOError</code> anytime I try to save an image like this.</p>
  
  <p>Normally I would assume I was just doing something silly with my directory structure, but the same pattern of <code>url_for</code> works perfectly for files in my static directory. Any ideas on how to remedy this? Here's my directory structure (trimmed down for viewing)</p>
  
  <pre><code>├── SpoolEngine
  │   ├── admin.py
  │   ├── __init__.py
  │   ├── templates
  │   │   ├── admin
  │   │   │   ├── base.html
  │   │   ├── base.html
  │   │   ├── _forms.html
  │   │   ├── posts
  │   │   │   ├── complete.html
  │   │   └── super_user
  │   │       ├── base.html
  │   ├── users.py
  │   └── views.py
  └── static
      ├── css
      │   ├── admin.css
      │   └── zebraTable.css
      ├── img
      │   └── subtle_grunge.png
      ├── js
      │   ├── compatibility.js
      │   ├── list.js
      │   ├── login.js
      │   └── profiler.js
      └── products
  </code></pre>
  
  <p>And for reference, url_for works perfectly within <code>/static/css</code> and links to the wrong url from <code>admin.py</code> Any ideas?</p>