在做文件上传的时候出现了一点问题,将同一个文件上传到两个不同的目录,请问怎么实现,我写了一下,文件总是上传到一个目录.
<?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;
}
?>

解决方案 »

  1.   

    move_uploaded_file($fileControl['tmp_name'],"/AppServ/www/userSystem/goods/good/img/goodsPic/".$fileName); 
    move_uploaded_file($fileControl['tmp_name'],$path.$fileName$path 这个变量的值是什么?
    估计是等于"/AppServ/www/userSystem/goods/good/img/goodsPic/"所以才会放到同一目录下。
      

  2.   

    这个....都说了是MOVE啊...你上传的TMP文件已经被你第一个MOVE到一个地方了,还怎么再继续MOVE呢?