vendredi 4 septembre 2015

Unable to write in the ... directory Laravel

i have a problem uploading photos in a existing folder. When i upload a new photo forexample (1).jpg i will split it by whitespace , get the forexample name ,create a folder with that name and upload the picture in that folder. All fine and dandy but when i upload another photo forexample (2).jpg to go in the forexample folder laravel gives me the error Unable to write in the "....../forexample/" directory.

The code looks like this.It is within a controller. Thank you peeps in advance.

if(Input::file('poze')[0] != null){ 
        //make folder name
            $foldername = explode(' ',Input::file('poze')[0]->getClientOriginalName())[0];

        //make folder path
            $path = substr(storage_path(),0,27).'pozeproduse/';

            if(File::exists($path.$foldername) == false){

                //create folder
                File::makeDirectory($path.$foldername,0777);

                    Input::file('poze')[0]->move($path.$foldername.'/',Input::file('poze')[0]->getClientOriginalName());
                    $poze = new Poze();
                    $poze->poza = substr($path.$foldername.'/'.Input::file('poze')[0]->getClientOriginalName(),26,64);
                    $poze->produs_id = $this->request->input('idp');
                    $poze->save();


            }else{  
                //dd($path.$foldername);
                    //foreach(scandir($path.$foldername) as $d){
                    //  if($d != Input::file('poze')[0]){

                                $obj= new \stdClass();
                                $obj->poza = Input::file('poze')[0];

                                $obj->poza->move($path.$foldername.'/',Input::file('poze')[0]->getClientOriginalName());
                                //dd('break');

                                $poze = new Poze();
                                $poze->poza = substr($path.$foldername.'/'.Input::file('poze')[0]->getClientOriginalName(),26,64);
                                $poze->produs_id = $this->request->input('idp');
                                $poze->save();

                    //  }   
                    //}
            }
        }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1KOPC6K
via IFTTT

Aucun commentaire:

Enregistrer un commentaire