php - Move a file and rename it -


figured php's rename best bet. didn't see many examples on how use relative urls in though, kind of compromised. either way, give me permission denied:

i want this:

$file = "../data.csv"; rename("$file", "../history/newname.csv"); 

where ../ of course go 1 directory script being ran. couldn't figure out way...so did instead:

$file = "data.csv"; $path = dirname(realpath("../".$file)); rename("$path/$file", "$path/history/newname.csv"); 

however getting permission denied (yes history folder owned www-data, , yes data.csv owned www-data). thought weird tried simple test:

rename( 'tempfile.txt', 'tempfile2.txt' ); 

and made sure www-data had full control on tempfile.txt...still got permission denied. why? file renaming have exist? can not rename linux's mv? instead copy() , unlink()?

in order move file "../" "../history/", process needs write permission both "../" , "../history/".

in example, you're lacking write permission "../". permissions file being moved not relevant, way.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -