# Copying to clipboard, PHP



## Dustyshouri (Aug 10, 2006)

So I've seen plenty of sites that have textboxes with content, with a button next to them to that if you click it, copies the text to the clipboard. Is there any way I can do this in PHP?


----------



## Dustyshouri (Aug 10, 2006)

One more question. I'm making it so it logs whatever is uploaded, but I'm having problems with /n.

Here's the bit of code right here from the appending bit:

```
fwrite(fopen("uploadlog.txt", 'a'), "Uploaded file: $target_path\n");
fclose(fopen("uploadlog.txt", 'a'));
```
But here's the log:
Uploaded file: uploads/test.PNG Uploaded file: uploads/test.png Uploaded file: uploads/test.png Uploaded file: uploads/test.png

For some reason it's not writing the newline. Any help with that?


----------



## DJ-Zep (Mar 11, 2006)

Welcome to TSF! While I'm currently working on the copy to clipboard snippet, I'll answer your second question.


```
fwrite(fopen("uploadlog.txt", 'a'), "Uploaded file: $target_path<br>");
fclose(fopen("uploadlog.txt", 'a'));
```
For some reason, \n doesn't insert linebreaks for some people. Using <br> will insert an HTML line break.


----------



## DJ-Zep (Mar 11, 2006)

It seems as though the copy to clipboard feature only works in Internet Explorer.


----------



## grizzly_uk (Jul 28, 2006)

This can be achieved easily enough in HTML and works in IE, Mozilla and Opera. Have a gander at this http://dynamicdrive.com/dynamicindex11/selectform.htm

Whether it validates or not is another thing, you may need to tweak it to make it conform.


----------



## Dustyshouri (Aug 10, 2006)

Hmm, well thanks for your replies. About the linebreak, if it's being sent to a txt file, will an html break even work?


----------



## DJ-Zep (Mar 11, 2006)

Dustyshouri said:


> Hmm, well thanks for your replies. About the linebreak, if it's being sent to a txt file, will an html break even work?


Is it being displayed as HTML? If it is being displayed as a txt file, it will not work.


----------

