在做文件上传的时候出现了一点问题,请大家帮忙!
在做文件上传的时候出现了一点问题,将同一个文件上传到两个不同的目录,请问怎么实现,我写了一下,文件总是上传到一个目录.
<?php
function upload($fileControl,$path=UPLOADPATH,$ext=ALLOWFILETYPE,$size=MAXFILESIZE)
{
if ($fileControl['size'] > $size)
return 1001;
$ext = explode(",",$ext);
if (!in_array($fileControl['type'],$ext))
return 1002;
if (!is_uploaded_file($fileControl['tmp_name']))
return 1003;
$ext = explode(".",$fileControl['name']);
$ext = $ext[count($ext) - 1];
do
{
$fileName = time().(microtime()*pow(10,6)).".".$ext;
}while (file_exists($path.$fileName));
move_uploaded_file($fileControl['tmp_name'],"/AppServ/www/userSystem/goods/good/img/goodsPic/".$fileName);
if (move_uploaded_file($fileControl['tmp_name'],$path.$fileName))
return $fileName;
else
return 1004;
}
?>