View Full Version : How do you store image path to database?
mkondakow
04-30-2009, 05:37 PM
I'm trying to store the path to my images into my MySql database. The problem is that the path is recorded but the dashes are not present?
i.e. I should get "\images\hiking\trees.jpg " instead i get "imageshikingtrees.jpg "
Also can DFP create directories on the server from a database field such as the persons unique Id_user field?
Ray Borduin
05-01-2009, 06:35 AM
If the proper permissions are set it should create directories that are specified and don't exist.
If you want the server directory, that is a separate binding from the server file name. Just combine the two in the insert and update server behavior if you want both stored.
mkondakow
05-01-2009, 03:16 PM
Hello Ray
Tried your suggestion with no results.
All I'm getting is the uploaded filename in the root directory.
Spent too many hours on what should be simple.
I have a local wamp server with all permisions on.
Lets try again.
First step I want to creat a directory on the server called images.(currently it doesn't exsist)
Please give me the steps (detailed) for the server behaviours for DFP , Data assist insert file and update file.
When we get that figured out i need the instructions to record the path to the images folder and file names in my database field.
By design DFP wont store the path to the file in the database. It stores the file name.
You can then simply add the path to the dynamic image on the detail page so it would read something like
/public/images/members/<%=rs_member.fields.item("image")%>
All upload components I have used only ever store the image name. You may be able to store the directory using the bindings for DFP - not sure, never tried it.
mkondakow
05-01-2009, 04:33 PM
Thanks Ian
That is a great suggestion.
Do you know if DFP will create a new directory if it doesn't exsist yet on the server?
I.E.
I tried an expieriment, made a directory called images. Followed the DFP wizard and my file was upload to directory images.
Now if i remove the directory and try the whole process again DFP does not create the requested directory called images.
Is this another feature that DFP not do?
Hi,
Yes, from my experience, as long as the parent directory of the upload path has permissions to create directories then DFP will automatically create it if it doesnt exist.
This is true on a Windows box and an ASP site. I am relatively new to PHP and don't have much experience of using DFP on PHP but I assume that functionality will be the same across platforms.
Cheers
Ian
mkondakow
05-02-2009, 09:32 AM
Thanks Ian
Ok so you have confirmed that a new directory can be created on a Windows box with ASP.
Can some one from Webassist confirm if this is true with a windows box running PHP?
Danilo Celic
05-04-2009, 09:36 AM
In some circumstances, the folder won't be created. In fact this is one of the fixes that will be in the next update of Digital File Pro V1. Sorry I can't give any dates as testing is still underway.
However, if you open up this file:
WA_DigitalFilePro/HelperPHP.php
And go down to the bottom and look for the rootRelativeToFullFileURLfunction and replace it with the following:
function rootRelativeToFullFileURL($folderPath){
if(strpos($folderPath, "/") === 0){
$scriptName = $_SERVER['SCRIPT_NAME'];
$currentFilePath = realpath(basename($scriptName));
$replaceBackSlash = preg_replace('/\\\/', '/', $currentFilePath);
$scriptNameRegEx = "/".preg_replace("/\\//", "\\/", $scriptName)."$/";
$folderPath = preg_replace($scriptNameRegEx,"", $replaceBackSlash).$folderPath;
}
else{
$separator= WA_DFP_GetFileSeparator();
// Use correct separator
$origFolderPath = preg_replace('/\\\|\\//', $separator, $folderPath);
$folderPath = realpath('./').$separator.$origFolderPath;
// drop any trailing slash, as realpath doesn't return it either.
$folderPath = preg_replace("/\\".$separator."$/", "", $folderPath);
}
return $folderPath;
}
That should help make sure the folder is getting created. If not, then please do log a support incident (http://www.webassist.com/mywebassist/techsupportinsert_1.php) as your specific setting may lead to a different issue.
Danilo Celic
05-04-2009, 09:39 AM
Oh, one note. Please keep that snippet on hand, as each time you make an update or add a new instance of any of the Digital File Pro server behaviors (Delete, Download, Rename, Upload) will overwrite this change. So make sure to keep this code chunk around to make the change again.
mkondakow
05-04-2009, 11:33 AM
Thanks Danilo
Thats what I needed to know.
I'm Glad your team is working on DFP updates.
Its a fundamental module for CMS work
Mickey
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.