mercredi 16 mars 2016

Storing image to Public folder Laravel 5.1

I'm trying to save an image to a folder in my laravel application.

I'm getting the error:

fopen(F:\blog\public/usr-data/photos): failed to open stream: Permission denied

Here's my laravel controller which is writing to this folder.

        $error                  = false;
        $absolutedir            = public_path();
        $dir                    = '/usr-data/photos';
        $serverdir              = $absolutedir.$dir;
        $filename               = array();

        foreach($_FILES as $name => $value) {
            $json                   = json_decode($_POST[$name.'_values']);
            $tmp                    = explode(',',$json->data);
            $imgdata                = base64_decode($tmp[1]);

            $fileAry = explode('.',$json->name);
            $extension = strtolower(end( $fileAry ));

            $fname                  = $card->id.'.'.$extension;

            $handle                 = fopen($serverdir,'w');
            fwrite($handle, $imgdata);
            fclose($handle);

            $filename[]             = $fname;
        }

I've tried using

Icacls "F:\blog\public/usr-data/photos" /grant Everyone:(OI)(CI)F

But no joy - still the same issue.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire