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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC