Home > Backend Development > PHP Tutorial > 这是PHP上传文件代码,怎样更换上传目录

这是PHP上传文件代码,怎样更换上传目录

WBOY
Release: 2016-06-23 13:56:12
Original
891 people have browsed it

foreach($_FILES as $f)
{
//处理中文名
if (function_exists("iconv"))  $f[name] = iconv("UTF-8","GB2312",$f[name]);
//检查是否已经存在同名文件
if (file_exists($f[name]))  header("HTTP/1.0 403");
//保存文件
if (!@move_uploaded_file($f["tmp_name"],$f[name]))  header("HTTP/1.0 404 Not Found");
echo "1";
}
怎样把上传目录换成D://www这个文件夹下?


回复讨论(解决方案)

move_uploaded_file($f["tmp_name"], ‘d:/www/' . $f[name])
Copy after login
Copy after login

move_uploaded_file($f["tmp_name"], ‘d:/www/' . $f[name])
Copy after login
Copy after login


怎样获取到文件名呢?比如文件名为a.txt 。获取结果$name = a

$name = pathinfo('a.txt', PATHINFO_FILENAME);echo $name;
Copy after login

不明白你在说什么

$name = pathinfo('a.txt', PATHINFO_FILENAME);
echo $name;

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template