重命名文件 rename(原来的名字,修改后的名字)名字的路径也要写完整 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 bool rename( string oldname, string newname) 我是过了,不行。oldname,newname 都是文件名不行。oldname,newname 都是带虚拟目录的文件名还是不行。我的虚拟目录为 " ../php111 "是不是虚拟目录的缘故? rename( string oldname, string newname)oldname,newname 都是带虚拟目录的文件名还是不行。出现Warning: Rename failed (Invalid argument) in C:\apache\htdocs\rjb\xb\upload_1.php3 on line 74错误。 代码如下:<form enctype="multipart/form-data" name="submitform" action="upload_1.php3" method="post"> <input type="hidden" name="max_file_size" value="1000000"> <input type="hidden" name="uploadaction" value="1">..............................<td width="76">添加文件</td> <td width="316"> <input name="uploadfile" type="file" size="30"></td> </tr> <td width="76" > <input name="submit" value="提交" type="submit"></td>------upload_1.php3代码----------.........$uploadaction=0;$timelimit=600;$date=date("h:i:s A");set_time_limit($timelimit);if(($uploadfile!="none")&&(uploadfile!="")){ $uploadpath="../php111/"; $uploadfile_name1.=$date;$filename =$uploadpath.$uploadfile_name;$ext=substr($filename,strrpos($filename,".")+1);//echo $ext;得出文件扩展名$wjm=$date;$point=".";$wjm.=$point;$wjm.=$ext;//echo $wjm; //重新命名文件,利用上传时间+“.”+原扩展名$path1=substr($filename,strrpos($filename,"/")+1);//得到最右边的"/"之后的字符串儿if($uploadfile_size<1024) { $filesize=(string)$uploadfile_size."字节"; } elseif($uploadfile_size<(1024*1024)) { $filesize=number_format((double)($uploadfile_size/1024),1)."KB"; } else { $filesize=number_format((double)($uploadfile_size/(1024*1024)),1)."MB"; } if(!file_exists($filename)) { if (copy($uploadfile,$filename)) { $order_file=$uploadpath; $order_file.=$wjm; //echo $order_file; 在新生成的文件前加上虚拟路径 rename($filename,$order_file); echo "文件 $uploadfile_name($filesize)上载成功!"; } else { ?><script language="javascript"> alert("上载失败,请核实!") history.go(-1) </script> <? } unlink($uploadfile); }........ 运行后出现上面的错误。帮我看看,谢谢! 我的思路:..................得到上传文件——〉取其文件扩展名——〉得到上传时间,在时间后面加上扩展名——〉得到虚拟目录(文件上传到的文件夹 "../php111")——〉把新建的文件名+虚拟目录 (两者相结合)——〉在传过来的文件进行重命名..................明白吗? 好长呀你直接将rename($filename,$order_file);里面的参数echo 出来看看吧 我echo 过分别是 .../php111/abcd.gif .../php111/11:24:39 AM.gif感觉没问题呀 .../php111/11:24:39 AM.gif这里面不是有两个: 我是菜鸟,大哥大姐快来,问个str_replace替换的问题 (北京)某外资B2C网站诚聘脚本工程师! ZABBIX 页面刷一下,mysql的进程就不停的增加 求助联级菜单问题!!!急。 一段兼容firefox浏览器JS代码出现问题。 MsSQL Server&PHP的分页程序 请问,大家使用哪种PHP的编辑器比较好? 欲高价购买一套类似碧聊的语音聊天程序. UP者有分! PHP从access数据库中如何取日期型字段? php调用Python问题 win2k+apache+php:为何浏览php文件变为下载? 一些论坛的[url]www.csdn.net[/url]的自动转换究竟怎么做?
oldname,newname 都是文件名不行。
oldname,newname 都是带虚拟目录的文件名还是不行。
我的虚拟目录为 " ../php111 "
是不是虚拟目录的缘故?
oldname,newname 都是带虚拟目录的文件名还是不行。
出现
Warning: Rename failed (Invalid argument) in C:\apache\htdocs\rjb\xb\upload_1.php3 on line 74
错误。
<form enctype="multipart/form-data" name="submitform" action="upload_1.php3" method="post">
<input type="hidden" name="max_file_size" value="1000000">
<input type="hidden" name="uploadaction" value="1">
..............................
<td width="76">添加文件</td>
<td width="316">
<input name="uploadfile" type="file" size="30"></td>
</tr>
<td width="76" >
<input name="submit" value="提交" type="submit"></td>
------upload_1.php3代码----------
.........
$uploadaction=0;
$timelimit=600;
$date=date("h:i:s A");
set_time_limit($timelimit);
if(($uploadfile!="none")&&(uploadfile!=""))
{ $uploadpath="../php111/";
$uploadfile_name1.=$date;
$filename =$uploadpath.$uploadfile_name;
$ext=substr($filename,strrpos($filename,".")+1);
//echo $ext;得出文件扩展名
$wjm=$date;
$point=".";
$wjm.=$point;
$wjm.=$ext;
//echo $wjm; //重新命名文件,利用上传时间+“.”+原扩展名
$path1=substr($filename,strrpos($filename,"/")+1);//得到最右边的"/"之后的字符串儿
if($uploadfile_size<1024)
{
$filesize=(string)$uploadfile_size."字节";
}
elseif($uploadfile_size<(1024*1024))
{
$filesize=number_format((double)($uploadfile_size/1024),1)."KB";
}
else
{
$filesize=number_format((double)($uploadfile_size/(1024*1024)),1)."MB";
}
if(!file_exists($filename))
{
if (copy($uploadfile,$filename))
{
$order_file=$uploadpath;
$order_file.=$wjm;
//echo $order_file; 在新生成的文件前加上虚拟路径
rename($filename,$order_file);
echo "文件 $uploadfile_name($filesize)上载成功!";
}
else
{ ?>
<script language="javascript">
alert("上载失败,请核实!")
history.go(-1)
</script> <? }
unlink($uploadfile);
}
........
运行后出现上面的错误。
帮我看看,谢谢!
..................
得到上传文件——〉取其文件扩展名——〉得到上传时间,在时间后面加上扩展名——〉得到虚拟目录(文件上传到的文件夹 "../php111")——〉把新建的文件名+虚拟目录 (两者相结合)——〉在传过来的文件进行重命名
..................
明白吗?
你直接将rename($filename,$order_file);里面的参数echo 出来看看吧
分别是 .../php111/abcd.gif
.../php111/11:24:39 AM.gif
感觉没问题呀
这里面不是有两个: