<HTML ><HEAD ><TITLE >copy</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Filesystem functions" HREF="ref.filesystem.html"><LINK REL="PREVIOUS" TITLE="clearstatcache" HREF="function.clearstatcache.html"><LINK REL="NEXT" TITLE="delete" HREF="function.delete.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.clearstatcache.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.delete.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.copy" ></A >copy</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN25117" ></A ><P > (PHP 3, PHP 4 )</P >copy -- Copies file</DIV ><DIV CLASS="refsect1" ><A NAME="AEN25120" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >copy</B > ( string source, string dest)<BR ></BR ><P > Makes a copy of a file. Returns <TT CLASS="constant" ><B >TRUE</B ></TT > if the copy succeeded, <TT CLASS="constant" ><B >FALSE</B ></TT > otherwise. <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN25134" ></A ><P ><B >Example 1. <B CLASS="function" >copy()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" >if (!copy($file, $file.'.bak')) { print ("failed to copy $file...<br>\n"); }</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > As of PHP 4.3.0, both <TT CLASS="parameter" ><I >source</I ></TT > and <TT CLASS="parameter" ><I >dest</I ></TT > may be URLs if the "fopen wrappers" have been enabled. See <A HREF="function.fopen.html" ><B CLASS="function" >fopen()</B ></A > for more details. If <TT CLASS="parameter" ><I >dest</I ></TT > is an URL, the copy operation may fail if the wrapper does not support overwriting of existing files. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Warning</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > If the destination file already exists, it will be overwritten. </P ></TD ></TR ></TABLE ></DIV ><P > See also <A HREF="function.move-uploaded-file.html" ><B CLASS="function" >move_uploaded_file()</B ></A >, <A HREF="function.rename.html" ><B CLASS="function" >rename()</B ></A >, and the section of the manual about <A HREF="features.file-upload.html" >handling file uploads</A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.clearstatcache.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.delete.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >clearstatcache</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.filesystem.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >delete</TD ></TR ></TABLE ></DIV ></BODY ></HTML >