david001's avatar

Unable to upload Image on live site

I have a live site where their is member registration .All data will be saved but i got one error the error is like this

Could not move the file "/tmp/phpa4pH3I" to "/home/sporter/public_html/someonect.org/uploads\membersImages/33921.jpg" ()

my code is live this

public function store(){
        // dd(Input::all());
       $validator = Validator::make(Input::all(), Members::$rules);

       if($validator->passes()):

 $first_name = Input::get('mem_firstName');
    $last_name = Input::get('mem_lastName');
    $email = Input::get('mem_email');
    $image = Input::get('mem_image');
    $phone = Input::get('mem_phone');
    $occupation = Input::get('mem_occupation');
    $citizen = Input::get('mem_citizen');
    $address = Input::get('mem_address');

    $destinationPathImage = str_replace('PROJECT\\', '', base_path().'\uploads\membersImages\\') ;

                 //Generating a random name
    $randomName = rand(11111,99999);

                //Renaming the image
                $ImageName = $randomName.'.'.'jpg'; // renameing image

                $imagePath = $destinationPathImage.$ImageName;

                Members::create([
                    'first_name'=>$first_name,
                    'last_name'=>$last_name,
                    'email'=>$email,
                    'image'=>$imagePath,
                    'phone'=>$phone,
                    'occupation' => $occupation,
                    'citizen' => $citizen,
                    'address'=>$address
                    ]);
...
0 likes
6 replies
david001's avatar

images path saved to database but not uploaded in folder

veve286's avatar

@david001 See that path . It is wrong /uploads\membersImages/ It should be /uploads/membersImages/ . See the different ?

"/home/sporter/public_html/someonect.org/uploads\membersImages/33921.jpg" ()

david001's avatar

@veve286 how should i change this path $destinationPathImage = str_replace('PROJECT\', '', base_path().'\uploads\membersImages\') ;

PROJECT is my laravel file directory

veve286's avatar

@david001 where you want to store your image tell me exactly ? In your public folder or what ?

david001's avatar

@ veve286 It is in PROJECT Directory ie in same line of PROJECT folder i have uploads/membersImages folder

sid405's avatar

@david001

 $destinationPathImage = str_replace('PROJECT\\', '', public_path().'/uploads/membersImages/') ;

In the 'public' dir make a directory called 'uploads' and inside that one called 'members'.

ps. Where is the string 'PROJECT\' coming from?

Please or to participate in this conversation.