Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using PHP to copy a file

Status
Not open for further replies.

hepower

Technical User
May 16, 2001
10
US
Someone suggested that I use php to copy files. I have a set file name "pic0" that is used and I want to copy a different file to "pic0" when a choice is made in a form. I have 7 (possibly more) different files... pic1,pic2,pic3...pic7 that I need to rename to "pic0" when that choice is made. i.e. the person selects picture2 so I want to copy "pic2" to "pic0" (I don't want to move "pic2" only copy it). Could someone please show me how this is done? Thanks.
 
You can use the php commant copy
copy (string source, string dest).

In your FORM you can can use a Text area like this:
<INPUT type=&quot;text&quot; name=&quot;filenumber&quot;>
where the user types the file number.
or you use another HTML tag like this:
<SELECT name=&quot;filenumber&quot;>
<OPTION>1
<OPTION>2
etc.
</SELECT>

you can submit this file to:

<?php
copy(&quot;pic$filenumber&quot;, &quot;pic0&quot;);
?>

P.S.
For choose a file from his harddisk the user of the form can also use:
For choose a file you can use:
<INPUT type=&quot;file&quot; name=&quot;fileupload&quot; size=&quot;20&quot;>

I hope this is the information you need.

Qwark




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top