Using images in PHP

Associate
Joined
12 Aug 2004
Posts
1,009
Location
Glasgow, Scotland
Hi folks,

I'm trying to implement images into my text-only PHP content management system.

Basically what I have so far is an admin area where a list of each page appears. The administrator can then click on a page which will take them to an editable page (editpage.php) displaying the title, text content & if the page will be in the menu or not .. with these options being editable by simply editing the desired text and then submitting the form.

I'd like to link to a page from the admin area where the admin can view all images that exist in the database and also have the ability to upload new images, then from inside editpage.php I would like a way for the admin to easily view all images stored in the database and be able to add in an image to a page, by typing for example <<imagename>> wherever they wanted the image to appear.

Is there any way of doing this? I'm really looking for some detailed info, maybe even a couple of tutorials for a way of implementing this feature into my existing php content management system as the book I have doesn't go this far ... it just stops once your able to format text properly.

Thanks for your time,

Steven.
 
Dj_Jestar said:
do you mean <<imagename>> as a keyword?

The 'simplest' route is a preg_replace:

Code:
$text = preg_replace('/<<([^<>])+>>/m', '<img src="$1" />', $text);

However, most use a stack based tokeniser which is a little more to go into, but is much more efficient for large numbers of replacements.

Ohh ... I never thought that was possible for some reason. I'm using the replace function already for font styling and tables, but I never really thought it could be used for images.

I get what you mean ... the <<imagename>> is suppost to be a keyword but from your code I can't figure out where the '1' variable comes from? Could you go into more detail if possible?

Also is there any easy to understand tutorials around showing you how to create an image upload script?

Thanks :)
 
Cheers, no idea what your on about but i guess i'll take a better look at doing it that way later on.
 
Back
Top Bottom