文件上传的若干问题
我的问题是在点击“上传”按钮时,出现move_uploaded_file()的问题。
我的代码:
[code=PHP][/code] for($i=0;$i
$insertsql = 'insert into tb_upfile(filename,filepath,filetype,upanthor,chkdownnum,ispub) values("'.trim($filename[$i]).'","'.$file_path.$filename[$i].'","'.$filetype[$i].'","houqingdong","'.trim($chkdownnum).'",'.$tmppub[$i].')';
try{
$dsn = "mysql:host=localhost;dbname=db_upan";
$db = new PDO($dsn,"root","");
$db->exec($insertsql);
$db = null;
}catch(PDOException $e){
echo '数据库操作发生错误';
}
}else{
echo "move_uploded_file出错!!";
}
}
出现的错误信息是:
Warning: move_uploaded_file(C://xampp/htdocs/upan/upfile/C:\xampp\tmp\phpD432.tmp) [function.move-uploaded-file]: failed to open stream: Invalid argument in C:\xampp\htdocs\upan\upfile_chk.php on line 33
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\phpD432.tmp' to 'C://xampp/htdocs/upan/upfile/C:\xampp\tmp\phpD432.tmp' in C:\xampp\htdocs\upan\upfile_chk.php on line 33
------解决方案--------------------
move_uploaded_file参数出错,可输出看一下
------解决方案--------------------
路径啊...Unable to move 'C:\xampp\tmp\phpD432.tmp' to
'C://xampp/htdocs/upan/upfile/C:\xampp\tmp\phpD432.tmp'
------解决方案--------------------
if(move_uploaded_file($tmpname[$i],$file_path.$filename[$i])==true){ //保存应该是原文件名吧
------解决方案--------------------
if(move_uploaded_file($tmpname[$i],$file_path.$tmpname[$i])==true)
move_uploaded_file(文件,新位置)
move_uploaded_file()这里前输出下,看路径位置对不对