function.move-uploaded-file.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 143 行
HTML
143 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Moves an uploaded file to a new location</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mkdir.html">mkdir</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.parse-ini-file.html">parse_ini_file</a></div> <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.move-uploaded-file" class="refentry"> <div class="refnamediv"> <h1 class="refname">move_uploaded_file</h1> <p class="verinfo">(PHP 4 >= 4.0.3, PHP 5)</p><p class="refpurpose"><span class="refname">move_uploaded_file</span> — <span class="dc-title">Moves an uploaded file to a new location</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>move_uploaded_file</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span> , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$destination</tt></span> )</div> <p class="para rdfs-comment"> This function checks to ensure that the file designated by <i><tt class="parameter">filename</tt></i> 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 <i><tt class="parameter">destination</tt></i>. </p> <p class="para"> 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> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">filename</tt></i></span> <dd> <p class="para"> The filename of the uploaded file. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">destination</tt></i></span> <dd> <p class="para"> The destination of the moved file. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> If <i><tt class="parameter">filename</tt></i> is not a valid upload file, then no action will occur, and <b>move_uploaded_file()</b> will return <b><tt>FALSE</tt></b>. </p> <p class="para"> If <i><tt class="parameter">filename</tt></i> is a valid upload file, but cannot be moved for some reason, no action will occur, and <b>move_uploaded_file()</b> will return <b><tt>FALSE</tt></b>. Additionally, a warning will be issued. </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: <b>move_uploaded_file()</b> is both <a href="features.safe-mode.html#ini.safe-mode" class="link">safe mode</a> and <a href="features.safe-mode.html#ini.open-basedir" class="link">open_basedir</a> aware. However, restrictions are placed only on the <i><tt class="parameter">destination</tt></i> path as to allow the moving of uploaded files in which <i><tt class="parameter">filename</tt></i> may conflict with such restrictions. <b>move_uploaded_file()</b> ensures the safety of this operation by allowing only those files uploaded through PHP to be moved. <br /> </p></blockquote> <div class="warning"><b class="warning">Warning</b> <p class="para"> If the destination file already exists, it will be overwritten. </p> </div> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.is-uploaded-file.html" class="function" rel="rdfs-seeAlso">is_uploaded_file()</a></li> <li class="member">See <a href="features.file-upload.html" class="link">Handling file uploads</a> for a simple usage example</li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mkdir.html">mkdir</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.parse-ini-file.html">parse_ini_file</a></div> <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?