php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64487 error move files
Submitted: 2013-03-22 10:25 UTC Modified: 2013-10-24 05:00 UTC
From: info at djdb dot be Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: info at djdb dot be
New email:
PHP Version: OS:

 

 [2013-03-22 10:25 UTC] info at djdb dot be
Description:
------------
When you move  a file like code

        public function Movetobackup($file){
            rename($this->HOME.$this->download.$file, $this->HOME.$this->backup.$file);//TODO BEFORE UPLOAD UNCOMMENT
            if($this->debug){print "!!! $file moved!!!";} 
            //touch($dest, filemtime($src));//reset of the time of a file 
        }
then wil i lost te file when php has not access to the dest dir.
so i think it is a important issiue

Test script:
---------------
class classe1  {
     private $dir = "";
 public function Movetobackup($file,$dir){
            rename($this->dir.$file, $dir.$file);//TODO BEFORE UPLOAD UNCOMMENT
            if($this->debug){print "!!! $file moved!!!";} 
            //touch($dest, filemtime($src));//reset of the time of a file 
 }
}

$test = new classe1();
$test->move("myfile.txt","/newdir");

Expected result:
----------------
 

Actual result:
--------------
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-29 21:08 UTC] mhitza at gmail dot com
Nope.

This issues a warning message when trying to do the move, and doesn't remove the source file

<?php
file_put_contents("text", " ");
rename("text", "/text");

PHP Warning:  rename(/text): failed to open stream: Permission denied in /tmp/file.php on line 3
 [2013-10-24 05:00 UTC] yohgaki@php.net
-Status: Open +Status: Not a bug
 [2013-10-24 05:00 UTC] yohgaki@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

rename() is not a "mv". You must specify filename, not dir of the destination.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 19:01:35 2025 UTC