<HTML ><HEAD ><TITLE >move_uploaded_file</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="mkdir" HREF="function.mkdir.html"><LINK REL="NEXT" TITLE="parse_ini_file" HREF="function.parse-ini-file.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.mkdir.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.parse-ini-file.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.move-uploaded-file" ></A >move_uploaded_file</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN26632" ></A ><P > (PHP 4 >= 4.0.3)</P >move_uploaded_file -- Moves an uploaded file to a new location</DIV ><DIV CLASS="refsect1" ><A NAME="AEN26635" ></A ><H2 >Description</H2 >bool <B CLASS="methodname" >move_uploaded_file</B > ( string filename, string destination)<BR ></BR ><P > This function checks to ensure that the file designated by <TT CLASS="parameter" ><I >filename</I ></TT > is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by <TT CLASS="parameter" ><I >destination</I ></TT >. </P ><P > If <TT CLASS="parameter" ><I >filename</I ></TT > is not a valid upload file, then no action will occur, and <B CLASS="function" >move_uploaded_file()</B > will return <TT CLASS="constant" ><B >FALSE</B ></TT >. </P ><P > If <TT CLASS="parameter" ><I >filename</I ></TT > is a valid upload file, but cannot be moved for some reason, no action will occur, and <B CLASS="function" >move_uploaded_file()</B > will return <TT CLASS="constant" ><B >FALSE</B ></TT >. Additionally, a warning will be issued. </P ><P > This sort of check is especially important if there is any chance that anything done with uploaded files could reveal their contents to the user, or even to other users on the same system. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B >When <A HREF="features.safe-mode.html" >safe mode</A > is enabled, PHP checks whether the files or directories you are about to operate on have the same UID (owner) as the script that is being executed.</P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > <B CLASS="function" >move_uploaded_file()</B > is not affected by the normal <A HREF="features.safe-mode.html#ini.safe-mode" >safe mode</A > UID-restrictions. This is not unsafe because <B CLASS="function" >move_uploaded_file()</B > only operates on files uploaded via PHP. </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.is-uploaded-file.html" ><B CLASS="function" >is_uploaded_file()</B ></A >, and the section <A HREF="features.file-upload.html" >Handling file uploads</A > for a simple usage example. </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.mkdir.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.parse-ini-file.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >mkdir</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" >parse_ini_file</TD ></TR ></TABLE ></DIV ></BODY ></HTML >