PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

File upload on multisite

  1. The file upload folder rewrite rule is not applying to links that Gravity Forms gives me on the upload of a file. The generated link http://URL/networksite/files/gravity_forms/1/2011/06/filename.pdf gives a 404 error, but accessing it in the directory using http://URL/wp-content/blogs.dir/2/files/gravity_forms/1/2011/06/filename.pdf does work. Files under the usual year/month folders do work correctly. It's not a problem to access the files via FTP for me, but it would be nice to access them using the generated links. Is there something I'm doing wrong, or is this a problem with multisite?

    Posted 13 years ago on Monday June 27, 2011 | Permalink
  2. The file paths for uploaded files should look something like this:

    http://URL/wp-content/uploads/gravity_forms/...

    The examples you gave don't appear to be correct. Gravity Forms uploads file upload field files to the wp-content/uploads/gravity_forms folder in subfolders and the URL to that shouldn't use URL rewriting, it should point to the wp-content/uploads/gravity_forms/ directory in the URL itself.

    Posted 13 years ago on Monday June 27, 2011 | Permalink
  3. As usual, it was something that I didn't notice that was at fault - the file name (which I changed in my example) had an apostrophe in it, which was getting escaped by the multisite file handler and throwing a 404. Perhaps sanitizing filenames would be a nice feature, in the same way regular WP uploads are done? In the meantime, I'll just warn my users to stay away from apostrophes and quotes.

    Also, on multisite, network sites by default use /files/ instead of /uploads/, which is actually located at /wp-content/blogs.dir/{SITE_ID}/files/ and /wp-includes/ms-files.php handles getting the file appropriately. ms-files.php uses a $_GET variable for the file path, hence the extra slash that caused the 404. Happily, Gravity Forms does upload to the appropriate network site's file folder and all is well without apostrophes in the filename :) Thanks for taking a look.

    Posted 13 years ago on Monday June 27, 2011 | Permalink

This topic has been resolved and has been closed to new replies.