I need to allow my customer to upload a picture and then display the image source tag for the picture so they can copy it and paste it where they want to in the text area I am providing for them. i.e. how facebook notes works

Member Avatar for LastMitch

@GraficRegret

need to display <img src => as text on a page

I don't know about Facebook feature. But this question is more suited for CSS than PHP but to answer your question it should look like this:

<img src="image/image.jpg" width="800px" height="600px" alt="caption or text" />

The alt is where the caption appear.

I know how to use it I need to be able to "echo" it to a page so the person uploading the photo to the server can copy and paste it because they don't know how to write code and they don't want to know how.

Member Avatar for LastMitch

@GraficRegret

I know how to use it I need to be able to "echo" it to a page so the person uploading the photo to the server can copy and paste it because they don't know how to write code and they don't want to know how.

1) You need to create a simple form to submit the caption
2) You need to create a table in the database so when you submit your data from the form it will go to the database.
3) The you need to create a query to select the caption.
4) Now you can just echo the caption (wherever your image is place)

Does that make sense?

If you need to show HTML source code on a HTML page, run the HTML source through the htmlentities() function. That will convert it so the browse will show it as text rather than render it as HTML.

Or you could slap some <code></code> tags around it.

Member Avatar for LastMitch

@GraficRegret

If you are gonna to used htmlentities() function, your client won't be able to echo out the caption correctly because of the backslashes. This is the only drawback. It really depend how you used this function.

Or you could slap some <code></code> tags around it.

That's not enough. Neither the <code> nor <pre> tags will stop the browser from actually rendering HTML strings. They are simply styling tags; essentially the equivalent of using <span> or <p> tags with monospace fonts and white-spaces preserved.

There is one thing worth pointing out though. If you echo the unmodified HTML code into a <textarea>, most browsers will not render it as HTML, but rather show the HTML source in the area. However you should still encode the HTML entities with the htmlentities function. It's unwise to leave any HTML code that isn't actually meant to be rendered as HTML in there unmodified.

If you are gonna to used htmlentities() function, your client won't be able to echo out the caption correctly because of the backslashes.

How do you mean? The htmlentites function does not generate any backslashes. All it does is convert all applicable characters in the given string to their respective HTML entities. Are you perhaps confusing this with the addslashes function?

thanks for the help yall, i will mark as solved for the time being and after i find out what works i will reply to you all in thanks ro ask for mor help, thanks for your time

thank you all very much the code that you gave me works beautifully you were all very helpfull.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.