开发者

How to replace a file with another file of same name which has new content in PHP?

I am new to PH开发者_JS百科P. In my application user when clicks for PDF, a copy on his name will be stored in a server. Next time, when he wants another PDF of different data, even that also will be stored on the same name in the server. I want to replace the old copy with the new PDF. Please tell me how to solve it. Thank You.


Use copy($source, $dest) and the destination will always be overwritten if it exists.

See: http://www.php.net/manual/en/function.copy.php


Billy Moon's answer will work, but you can also use file_put_contents() and file_get_contents().

Heres how one might do that:

file_put_contents('user_file_new.pdf', file_get_contents('user_file_old.pdf'));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜