PDA

View Full Version : is it possible to add an Image


neuro
04-23-2007, 09:28 AM
Yo.. david got some question again.

Right now i'm trying to improve the update content part (which is a text area). i was wondering if i can give an option to add a picture inside the content.

so is it possible to add this html code

<img src=""/>

into the text area, when i click a button? then the user can just fill in the path of the image?

davidj
04-23-2007, 11:38 AM
you can key that code into your field or you can add it automaticaly using a checkbox

neuro
04-23-2007, 12:21 PM
hm... checkbox..

what about a button? like in the forum when u reply a post, u just need to click the "insert image" button.

javascript or php?

davidj
04-23-2007, 01:10 PM
so you add text and if you want an image then you would click a button

how do you select an image

does the image live on the clients machine or does the server have an image to choose from

do you have to upload the image

neuro
04-23-2007, 03:20 PM
let say the image is already in the server (i.e path "image/sample.jpg") so when the "insert image" button is clicked, in text area the code bellow


<img src=""/>


appear on the text area beside that is it possible to resize the image, in case the image is too big.

davidj
04-23-2007, 03:25 PM
you can resize the images using HTML attributes but this is not the best way to do this

i would never do it this way

you can use PHP to manipulate the image but this becomes more advanced

neuro
04-23-2007, 07:05 PM
k.. maybe can put the resize image to the side first.

so how do i make the img tag appear in the text box?

davidj
04-23-2007, 07:35 PM
dont need to make it appear at all

when you catch the data in your script just do...


if($_POST['image']){//<< image is the name of the field that has image name

$image = "<img src=\"".$_POST['image']."\"/>";

}

echo $image;

neuro
04-23-2007, 07:45 PM
by looking at the code given,

i have to create a new text box named "image" to store the image name (or is it the image path?)

so when i echo $image it will automatically insert <img src="PATH"/>

pls.. correct me if i'm wrong.

davidj
04-23-2007, 07:50 PM
if the images are kept in the same place then it would be better to insert this path hardcoded into the code. So the user doesnt have to key the path as it wont ever change

it would be better to use a dropdown with all your image names then there wouldnt be a problem with typos


if($_POST['image']){//<< image is the name of the field that has image name

$image = "<img src=\"path/path/".$_POST['image']."\"/>";//<< notice path

}

echo $image;

neuro
04-23-2007, 07:51 PM
Alright...

i'll try this out by tomorrow.

Thanks david.