How to rename t开发者_StackOverflow社区he file using PHP(in linux). I am using rename(oldfile,newfile), but not working.
rename("s3://mydata/$md5_userid/temp_$id.html","s3://mydata/$md5_userid/$iRow_id.html");
It looks like you're using a stream wrapper for Amazon S3.
It's up to the individual, custom wrapper code to implement rename functionality. If your wrapper isn't doing the rename, then either the code it's using is buggy, or it doesn't implement that functionality and either isn't reporting it, or you aren't checking the return code from the rename
function call and it's returning false to signify failure.
You will probably need to actually use the normal S3 API to perform your file rename. If the function is actually returning true, you should file a bug with the people that provided the stream wrapper library.
Edit: If you are using PEAR's Services_Amazon_S3 as suggested in the comments, then the stream wrapper it provides does do rename
using the rename
method starting at about line 570.
Edit2: After examining the code further, if there are failures, you will see warnings emitted from the stream wrapper. Perhaps you don't have error_reporting
cranked up all the way to -1
?
精彩评论