开发者

PHP permissions after file copy

I have a problem here for hours that I cannot figure out. I have a script that uploads pictures to a server. I also offer the possibility to erase pictures from开发者_StackOverflow中文版 the uploaded ones. This is working fine.

However, the user may want to 'publish' these pictures. When he does, they are copied to a new folder. If he wants to edit his gallery pictures are copied back to a temporal folder. After this happens, the files cannot be erased anymore, PHP doesn't want to. I checked the permissions and they are the same, and I'm also obtaining the owner of the file via fileowner() and it's the same owner both when the pictures can be erased and when they can't... Any ideas on what could be causing this?

Thank you!


Each time you are working with the pictures, are you making sure to close the file handle and/or the directory handle? If not, try doing that and then see if the pictures can be deleted.

fclose function

closedir function


Try to have a look at clearstatcache() I think this will solve your problem.

This function caches information about specific filenames, so you only need to call clearstatcache() if you are performing multiple operations on the same filename and require the information about that particular file to not be cached.

Have a look at the example in the docs, it clearly shows the problem with ownership for instance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜