rename为啥不好使啊?快疯了!!!(在线等) 我在move_uploaded_file后使用rename,返回提示说找不到文件,我又用chmod,file—exist都说找不到,但是上传的文件在目录里啊,而且我用rename做同一个目录里之前上传的文件就好使,怎么回事啊,这个问题已经搞了好几天了,受不了啦!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 相对路径,绝对路径都试过了。is_dir能过chmod不过file_exists不过但是要用上次上传的文件就能过,本次的就不过。我用的是cPanel系统,在本地的xampp就没问题 很正常,因为 move_uploaded_file 的文件的管理权还未交到操作系统你 sleep(1) 甚至 usleep(10000) 后就可以 rename 了就是不知道你为什么不一次到位呢? 我还真用了sleep,从sleep(1)到sleep(60),还是不行。因为我用了ajax的动态上传,用户有可能上传多次,但最后确定只上传一个文件,之前上传的都是废的,所以只把最后那个转移到真正存储的目录,这个tmp的目录定期清就行了。 $content = $_GET['storyContent']; $author = $_GET['storyAuthor']; $lastword = $_GET['lastword']; $imagefile = $_GET['imagefile']; if($imagefile == ''){ $imagefile = 'nopic'; }else { } mysql_query("insert into notes (content,author,date,lastword,image) values('".$content."','".$author."',NOW(),'".$lastword."','".$imagefile."')"); sleep(1); if(is_dir("../tmpImage")){ //die('tongguo'); } $path = dirname(__FILE__).'/'.$imagefile; if(!chmod ($path, 0755)){ die('buhaoshi'); } //var_dump($path); if(!file_exists($path)); { die($path); } die('guola'); if($imagefile != 'nopic' && file_exists("../tmp_image/".$imagefile)){ rename("../tmp_image/".$imagefile, "../upload/".$imagefile); } header("Location: ../index.php?lastword=".$lastword); if($this->Is_uploadDir() && $this->Is_FileMax()) { $this->get_newname(); $file_path=$this->g_Directroy.'/'.$this->g_doUpFile; if(!move_uploaded_file($_FILES[$this->g_filename]['tmp_name'], $file_path)) { $this->g_Error=5; return $this->get_error(); } else { $this->g_Error=0; return $this->get_error(); } 你都 die('guola'); 了,rename还有可能执行吗? 怎么实现这个的301跳转 ajax如何传中文参数? phpcms安装问题 请大家推荐一本学习php+mysql的书籍 问个登录的问题 帮忙找个帖子 介绍个基于php的mvc框架 md5加解密问题~~ 为什么连接ORACLE出先这样的错误? 遇到一个奇怪的事情 mysql能不能像access那样建立 发表回帖的实现过程
is_dir能过
chmod不过
file_exists不过
但是要用上次上传的文件就能过,本次的就不过。
我用的是cPanel系统,在本地的xampp就没问题
你 sleep(1) 甚至 usleep(10000) 后就可以 rename 了就是不知道你为什么不一次到位呢?
因为我用了ajax的动态上传,用户有可能上传多次,但最后确定只上传一个文件,之前上传的都是废的,所以只把最后那个转移到真正存储的目录,这个tmp的目录定期清就行了。
$author = $_GET['storyAuthor'];
$lastword = $_GET['lastword'];
$imagefile = $_GET['imagefile'];
if($imagefile == ''){
$imagefile = 'nopic';
}else {
}
mysql_query("insert into notes (content,author,date,lastword,image) values('".$content."','".$author."',NOW(),'".$lastword."','".$imagefile."')");
sleep(1);
if(is_dir("../tmpImage")){
//die('tongguo');
}
$path = dirname(__FILE__).'/'.$imagefile;
if(!chmod ($path, 0755)){
die('buhaoshi');
}
//var_dump($path);
if(!file_exists($path));
{ die($path);
}
die('guola');
if($imagefile != 'nopic' && file_exists("../tmp_image/".$imagefile)){
rename("../tmp_image/".$imagefile, "../upload/".$imagefile);
}
header("Location: ../index.php?lastword=".$lastword);
{
$this->get_newname();
$file_path=$this->g_Directroy.'/'.$this->g_doUpFile;
if(!move_uploaded_file($_FILES[$this->g_filename]['tmp_name'], $file_path))
{
$this->g_Error=5;
return $this->get_error();
}
else
{
$this->g_Error=0;
return $this->get_error();
}