Globally Update Image Storage Location

14 posts by 6 authors in: Forums > CMS Builder
Last Post: March 25, 2011   (RSS)

By johnnybegood - March 18, 2010 - edited: March 18, 2010

Hi all,

I purchased CMS Builder some months ago and deployed a website with little fuss. I liked this software so much that I just purchased 2 more copies.

The only frustrating issue I had with this software is that during development I was using a development server with a different root directory structure to the live server. This was fine except that when it came time to set the website "live" I had to manually go through and update all the previously uploaded images as their location was hard coded in the database.

I don't understand why the entire root location (ie. var/www/vhosts...etc) is required when storing images in the cms_uploads table. There is already a setting in admin where the Upload Directory is specified so couldn't this just be prepended to the image name? If the image name was the only thing stored then this would also enable transfer of a website to a websites sub-folder with minimal fuss. Currently this is a very laborious process; which I also discovered when I moved the development website from a "beta" folder to the domains root directory.

I am aware that it's possible to "recreate" thumbnails but this is not relevant to this particular issue.

Is there something I'm missing here or something I'm doing wrong?

Re: [johnnybegood] Globally Update Image Storage Location

By northernpenguin - March 18, 2010

Did you update all your section editors and the settings.dat.php file with the new directory path? I just did it for one of my development sites when I moved it into production, and everything worked well.
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

Re: [northernpenguin] Globally Update Image Storage Location

By johnnybegood - March 24, 2010 - edited: March 24, 2010

I updated the setting.dat.php but this still does not update the cms_uploads table. Similarly, nothing I do in the section editors has any affect on the existing (I stress existing) images which were uploaded during development on my localhost server.

This means I still have to manually go into the database and change entries within these 4 columns:

filePath
urlPath
thumbFilePath
thumbUrlPath

I cant see anything in this script that actively goes through and updates this information within the cms_uploads table based on the details present in settings.dat.php

Any help would be greatly appreciated.

Re: [johnnybegood] Globally Update Image Storage Location

By Dave - March 24, 2010

Hi johnnybegood,

It's a limitation of the current setup that full image paths are stored (instead of relative) and something that is on our todo list to address.

You can move data from one server to another the images will still display, but deleting them won't remove the file since the filepaths won't be accurate.

There's some technical reasons why we haven't gotten to this yet, but for now the quickest workaround for now is as follows:
- Click "Backup" under: Admin > General
- Download the new .sql backup file from /data/backups
- Create a backup copy of this file.
- Open the original in your favorite text or file editor
- Do a search and replace for "oldpath" to "newpath"
- Upload it and click restore

Basically: Backup -> Edit .sql file -> Restore

That's also a handy way to do other search and replaces if needed.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Globally Update Image Storage Location

By johnnybegood - March 25, 2010 - edited: March 25, 2010

Thanks Dave, that's a great work-around. I was previously doing search and replace directly on the database but working with a single flat file is a much simpler method.

Since you brought up backups I was recently thinking it'd be nice if the client could run the backup script without giving them full administrative rights. I tried creating a custom menu link to the backup script but it errors and I don't want to confuse the client by giving them full access. Is there an easy workaround for this?

Re: [johnnybegood] Globally Update Image Storage Location

By Dave - March 25, 2010

Checkout the Auto Backup script here:
http://www.interactivetools.com/add-ons/detail.php?Auto-Backup-1003

You just set your preferences and enable the plugin and it can automatically create and maintain rolling hourly, daily, weekly, and monthly mysql backups (so you'll always have backups the 3 hours, weeks, etc but minimize diskspace used). It can also automatically email you a zipped backup files.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Globally Update Image Storage Location

By JLynne77 - March 24, 2011

Hi, Dave,

I was wondering if this would be how to globally update file upload allowances.

For instance, I want to grant the ability to upload PDF files to content fields in multiple sections. Right now, I have to go through each section and add 'pdf' to the allowed files list individually.

Would I have to use this work around to do this across the board or is there already a global setting to do this that I might be missing?
-----
~Jessica Sullivan, Crystal Realm Designs.

Re: [Duches77] Globally Update Image Storage Location

By Jason - March 24, 2011

Hi Jessica,

Which version of CMS Builder are you using?

In the newer versions, the upload field defaults to allowing the following extensions:
gif,jpg,png,wmv,mov,swf,pdf

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Globally Update Image Storage Location

By JLynne77 - March 24, 2011 - edited: March 24, 2011

We have version 2.07. It's a fairly new install. It's not for an upload field specifically, but using the uploader through the WYSIWYG type of field. However, for each content field, I've had to add PDF to the list every time.
-----
~Jessica Sullivan, Crystal Realm Designs.