littlejones Posted October 17, 2006 Share Posted October 17, 2006 Hi,I need a little help with a site I've been building. I built the CMS part of a site and included within it FCKeditor text boxes with the functionality for users to upload images. Originally these images were uploaded to a folder in the CMS directory, and then the data from the form is saved into the database. Then, on the front end of the website I pull the data back out of the database and display it on the webpage.My problem is that I want the image to display on the front end and on the back end when the user originally uploads it. Because the CMS is in the CMS folder and the front end website is in the WWW folder I can't understand where I should be getting the images to upload to from the CMS and still enable them to be viewable on the front end. In other words I can't change the url for the file from when it is saved into the database to when it is pulled back out again. This is a problem because currently the files are being uploaded to /data/betawebs/lawrencelupin/www/uploaded_files from the CMS, and this enables them to be uploaded to the WWW folder instead of the CMS folder. However on the front end of the site the url is looking for the file at http://www.websiteaddress.net/data/betawebs/lawrencelupin/www/uploaded_files when really the file is stored in http://www.websiteaddress.net/uploaded_files I'm sure it is far far less complex than I've made it out to be, but I've either explained it really well or made it 10 times more confusing that it should be.I hope somebody can help! ;) Link to comment https://forums.phpfreaks.com/topic/24210-cms-and-www-folder-path-issue-less-complicated-than-it-sounds/ Share on other sites More sharing options...
michaellunsford Posted October 17, 2006 Share Posted October 17, 2006 for whatever reason, you're feeding the URL the comlete hard-drive path to the file (like realpath() might do). You just need to strip it out before presenting it to the browser. Without seeing code it would be difficult to suggest a real fix, but you can use pathinfo() to return just the filename without any directory information. http://us3.php.net/manual/fi/function.pathinfo.php[code=php:0]<?php$path_parts = pathinfo('/www/htdocs/index.html');echo $path_parts['dirname'], "\n";echo $path_parts['basename'], "\n";echo $path_parts['extension'], "\n";?>[/code]Would produce:/www/htdocsindex.htmlhtml Link to comment https://forums.phpfreaks.com/topic/24210-cms-and-www-folder-path-issue-less-complicated-than-it-sounds/#findComment-110131 Share on other sites More sharing options...
littlejones Posted October 18, 2006 Author Share Posted October 18, 2006 The problem is that because I'm using FCKeditor rather than my own upload feature I can't think of an easy way to change the path before it displays at the front end. So for instance, in the CMS the user clicks the image button built into the WYSIWYG editor (FCKeditor), uploads an image and then it is stored in that folder and displayed in the CMS textbox. The user then saves the record and it is sent straight to the database, along with all the other information in the text box, so for instance it could be stored as the following...blblabaablabal balablabalaba lots of information bla bla bla <img src="../../www/uploaded_files/" alt=""/> blasdf bla bla blasd more informationIn order for it to display in the CMS it needs the full file path as shown above, otherwise if I just put /uploaded_files/ it will create a new folder within the CMS direectory. So as you can see, when I pull this information back out of the database at the front end, for instance..."SELECT content FROM news"it just bring out everything and looks for an image at ../../www/uploaded_filesI'm not sure how I could write a simple piece of code to strip this off when it comes back out of the database, as I can't do it before otherwise it won't show in the CMS.Thanks Link to comment https://forums.phpfreaks.com/topic/24210-cms-and-www-folder-path-issue-less-complicated-than-it-sounds/#findComment-110555 Share on other sites More sharing options...
michaellunsford Posted October 18, 2006 Share Posted October 18, 2006 maybe you could replace that bit of string in the database query?For example, instead of just having $_POST['string_name'] you would put [code=php:0]str_replace("/data/betawebs/lawrencelupin/www","",$_POST['string_name']);[/code]. Link to comment https://forums.phpfreaks.com/topic/24210-cms-and-www-folder-path-issue-less-complicated-than-it-sounds/#findComment-110664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.