PHP create folder if it does not exist

前端 未结 4 705
无人及你
无人及你 2021-01-19 18:31

I am creating a medium size application.

This application consists of a lot of products.

Now these products have many images (one product can have 5 - 6 imag

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-19 18:49

    Try this:

    if (!file_exists('path/to/directory')) {
        mkdir('path/to/directory', 0777, true);
    }
    

    1) Does this automaticly create a new folder if it doesnt already exist. => file_exists and mkdir

    2) how can i give permission to a newly created folder so that i avoid this problem => 0777

提交回复
热议问题