vansant Posted March 28, 2010 Share Posted March 28, 2010 I'm creating a website for a family member. I'm not an html or php expert, just dabble enough until things look and feel right. I'm stuck on something and wondered if what I need is even possible - or maybe other ideas for what I'm trying to do. My folks are no good at any type of code, so keeping this simple is important. I've created a directory for my parents to log directly in and only view the pages that they can edit. This is their base directory in their ftp. (This would be referred to as /parentsfiles below) I'm using php to include the /parentsfiles/xxx.html file to create the body of the page (the part that changes frequently, and is editable by the folks). /parentsfiles /parentsfiles/index.html /parentsfiles/about.html /parentsfiles/contact.html /parentsfiles/image.jpg index.php about.php contact.php For simplicity, lets say the above structure is what you'd see upon FTP in. The index.php file contains all the real code for that page, the css, the menu, any other scripting - and the /parentsfiles/index.html file contains what their simple WYSIWYG editor creates for the body (no real html to speak of). This is to keep them from messing up the code of the main page. Follow? Now, when they upload an image (/parentsfiles/image.jpg) and call that image in their page, it doesn't bring it up. Of course it's looking for it in the base directory, not in the /parentsfiles/ directory where they've put it. THE QUESTION: Any code I can use in the index.php page to ensure all of the images include /parentsfiles/? Remember, I'm trying to make this simple for my parent's side, I'd rather do a bunch of work on my side to save them the hassle. OR - am I doing this the wrong way? Any other ideas to protect the valuable portions of the site while giving them free reign to their files and images? Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/ Share on other sites More sharing options...
GetPutDelete Posted March 28, 2010 Share Posted March 28, 2010 Yes, use the full URL when linking to images instead of relative links <img src="folder/image.jpg" /> Becomes... <img src="http://www.example.com/folder/image.jpg" /> Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033178 Share on other sites More sharing options...
GetPutDelete Posted March 28, 2010 Share Posted March 28, 2010 And to make it easy on your folks set the backend script to look for image files and append the full URL to them Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033180 Share on other sites More sharing options...
vansant Posted March 28, 2010 Author Share Posted March 28, 2010 And to make it easy on your folks set the backend script to look for image files and append the full URL to them This sounds like a good idea - could you point me to a tutorial on how to do such a thing? Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033183 Share on other sites More sharing options...
GetPutDelete Posted March 28, 2010 Share Posted March 28, 2010 Sure, so the backend script writes the data to a html file, right? Well just before it actually writes to the file you should do a search for <img src=" and replace it with <img src="http://mysite.com/ That way the end result will be <img src="http://mysite.com/imagefolder/image.jpg" /> To do this you need to use the str_replace function, I'm assuming the variable $body represents the HTML $body = str_replace('<img src="', '<img src="http://mysite.com/', $body); Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033188 Share on other sites More sharing options...
vansant Posted March 28, 2010 Author Share Posted March 28, 2010 Well I'm using php to include the body html file. The code is: <?php virtual("/parentsfiles/body.html"); ?> very similar to the ssi include command. Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033197 Share on other sites More sharing options...
GetPutDelete Posted March 28, 2010 Share Posted March 28, 2010 Ok, but when the HTML is saved to the files is when you want to add the full URL to the image path. Not when you are outputting it. Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033202 Share on other sites More sharing options...
vansant Posted March 28, 2010 Author Share Posted March 28, 2010 so explain like I'm new, cause I am... I am to put that code on the /parentsfiles/body.html file? And that will resolve the images? Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033249 Share on other sites More sharing options...
GetPutDelete Posted March 28, 2010 Share Posted March 28, 2010 Ok no problem, no not like that. What is the name of the file that takes the HTML from the editor that your parents use and then edits the existing HTML file with those changes? And if you paste the code in here I'll do it for you. Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033252 Share on other sites More sharing options...
vansant Posted March 29, 2010 Author Share Posted March 29, 2010 well there's two files. For instance: index.php -> this file contains the html, css, and code for the page. It uses the virtual command to bring in the body parentssite/index.html -> this file contains just the body text. no css, no code, nothing but the output of their editor. Also in the parentssite/ directory will be the images that they upload. If you'd like to chat offline, let me know and I'll pass you my info Link to comment https://forums.phpfreaks.com/topic/196814-path-to-images-htmlphp/#findComment-1033292 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.