lundi 2 janvier 2017

Checking folder already existed and if not create a new folder by id in laravel

i want to store my image to a specific folder and the folder will named by page id. For example if Page id=1, the folder location should be public/pages/page_id/image_here.

If the folder are not existed yet the system will generate and named with their page id.

 $id=1;
 $directoryPath=public_path('pages/' . $id);

if(File::isDirectory($directoryPath)){
        //Perform storing
    } else {
        Storage::makeDirectory($directoryPath);
        //Perform storing
    }

But i having error that "mkdir(): Invalid argument". Can i know why it happen?

And after my research some people say the folder name should based with id+token so intruder cannot search image based on id, is there possible to achieve?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire