Page 1 of 1

existing table field holds path+image.

PostPosted: Fri Jan 28, 2011 2:06 pm
by neotrode
Hello.

I am trying to create a simple backend using Xatabase to edit existing tables from an old website. The table in question has a field to hold the image filename and location relative to the root of the html folder. The php pages throughout the website rely on the field and its full path and filename.

Is there a setting I can turn on in Xataface to include (and use) the full path and filename of the image when it is uploaded?

With the current setup, I am using the /file folder from IMM and the image uploads save to the table with just the filename.

I am hoping there is a simple parameter to set for this option.

Thanks!

-Frank

Re: existing table field holds path+image.

PostPosted: Fri Jan 28, 2011 2:22 pm
by shannah
Storing just the filename is the most flexible because it frees you up to change the actual location where the files are stored. However, there are a number of ways to turn it into a path instead of just a file name. One way that I can think of is to create another field that just holds the filename, but use the beforeSave() trigger to populate the appropriate data in the other field (i.e. the one that should contain the path).

Another strategy would be instead to just add the path to the filename in the same column during the beforeSave trigger.. but there would likely be some other things you'd have to muck with in this approach to maintain compatibility with other Xataface functions that expect the field to only contain a file name.

-Steve

Re: existing table field holds path+image.

PostPosted: Fri Jan 28, 2011 2:34 pm
by neotrode
That's what I thought.

I was considering writing code to strip the paths from the column but then I would have to dig around all of the website's code and append the path to the IMG tags specific to image set etc... My gut tells me I am probably going to have to go that route.

I agree with you, saving just the filename is the way to go for the most flexibility but the old website did not have flexibility in mind.