rename file in php

后端 未结 4 1651
南方客
南方客 2020-12-18 00:50

I want to rename picture filename (without extension) to old.jpg from this code.

I have picture file in parent directory and t

4条回答
  •  星月不相逢
    2020-12-18 01:19

    Like Seth and Jack mentioned, the error is appearing because the script cannot find the old file. You're making it look in the current directory and not it's parent.

    To fix this, either enter the full path of the old file, or try this:

    rename("../picture.jpg", "old.jpg");
    

    The ../ traverses up a single directory, in this case, the parent directory. Using ../ works in windows as well, no need to use a backslash.

    If you are still getting an error after making these changes, then you may want to post your directory structure so we can all look at it.

提交回复
热议问题