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

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

WBOY
WBOYOriginal
2016-06-23 13:56:12873browse

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])

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


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

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

不明白你在说什么

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

Statement:
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