Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Upload of images in folder instead of database possible / recommended? [CKEditor]

+9 votes
asked Mar 4, 2012 in Plugins by q2apro
retagged Mar 4, 2012 by q2apro

Just now I realized that CKEditor uploads files into the database (table qa_blobs).

As far as I could see those images are not cached and thus result in slower server handling.

This is why I would like to ask how to change that behavior to have the files saved to a folder on the server, e.g. \uploads\images\

From my understanding, I have somehow to change the "qa-wysiwyg-upload.php" from line 102??


Searching the net regarding CKEditor (which is definitely pain) I found a little discussion about image uploads and absolute paths, if that helps: Image uploading in FCKeditor as well as kind of tutorial here.


I get a bit confused reading about folder vs. database in stackoverflow. Post by John Gietzen:

"FileStream solves most of the problems around storing the files in the DB:

  1. The Blobs are actually stored as files in a folder.
  2. The Blobs can be accessed using either a database connection or over the filesystem."

Others disagree...


What is Question2Answer using? What is the best way to serve cached images?

Q2A version: 1.5
commented Mar 5, 2012 by Scott
You should take a look at TinyMCE. IMO it's a more solid editor to start with, and uploading files to a folder is dead simple with a plugin.

1 Answer

+4 votes
answered Mar 5, 2012 by gidgreen

The caching of images in the end user's browser is unrelated to the way in which the images are stored on the server. When outputting a blob (including an image), Q2A adds an HTTP header to encourage caching at the client end (see qa-blob.php).

Having said that, if you want blobs to be stored as server files rather than in the database, you can write a plugin which overrides the following functions:






I'm sure other people would enjoy this plugin too!

commented Apr 28, 2012 by gidgreen
The issue of caching is independent of how the files are stored. Q2A sets the appropriate HTTP headers on images to allow them to be cached by proxies and browsers.
commented Apr 30, 2012 by Dude
You are right. Just most of scripts caching blobs bad. Your Q&A not, is ok. Thanks
commented May 4, 2012 by monk333
Want to comment that my interest in this is not caching but easier image handling and bandwidth. If I have thousand images in folders, i can resize them easily, if they are stored in the database I dont know an easy way to modify them. The other thing is, that on image based projects the images could be moved easily to a content delivery network.
commented Oct 15, 2013 by q2apro
@monk333: How is your experience, have you used the new feature of uploading to a folder instead to the db? ... Image Handling: Yes, it is easier to access it directly and resize it. Good point! And right, the images could be easily transferred to another storage. Thanks for pointing out these two essential advantages.