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还有可能执行吗? ADO连接循环输出 想要子目录里的动态链接变成静态链接 PHP 关于preg_match_all()函数,弱弱的问一下 散分,请各位谈谈php高手成长之路 PHP调用mysql函数出错 为什么老是提示超时?! 哪里可以下个PHP做的论坛或是聊天室呀? 用PHP存储图片或其他2进制文件报错问题?谢谢,急 请大家帮我看一段代码,是哪里出错 请教一个历史同期数据对比的问题 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();
}