how to updaload image twice with diffrent sizes : <p>hello i have project i work on , it have some issues ,</p>

<p>the problem here i need to get file twice once to move it and one with resizing </p>

<p>this is my code , what should i do here</p>

<pre><code> public function update_image(Request $request)
{
    $ad = Ad::where('id',$request-&gt;ad_id)-&gt;first();
    $photos= explode('||',$ad-&gt;photos);
    $thumbnails= explode('||',$ad-&gt;thumbnails);
    $number =  count($photos);
    $length = strlen($photos[$number-1]);
    $last_image_number = $photos[$number-1][$length - 5];
    // dd($photos[$number-1][$length - 5]);
    $last_image_number++;
    $image = $request-&gt;file('image');
    $image_name = 'preview_'.$last_image_number.'.'.$image-&gt;getClientOriginalExtension();
    $previews_path = public_path().'/uploads/images/'.$ad-&gt;ad_id.'/previews/';
    $thumbs_path = public_path().'/uploads/images/'.$ad-&gt;ad_id.'/thumbnails/';
    // $im = Image::make($image-&gt;getFullPath());
    chmod($previews_path,0777);
    $image-&gt;move($previews_path,$image_name);
    $photos[]= '/'.$ad-&gt;ad_id.'/previews/'.$image_name;
    $ad-&gt;photos = implode('||',$photos);
    $photo_path = basename($previews_path . $image_name);
    $ad-&gt;save();

    list($width, $heigh) = getimagesize($previews_path.$photo_path);
    $photo_path-&gt;move($thumbs_path,'ddd.jpg');
    dd($photo_path);
    // dd($width);
    $ratio = $width/ $heigh;
    $target_width = $width / $ratio;
    $target_height = $target_width / $ratio;
    $photo_path-&gt;resize($target_width,$target_height);

    $thumb_name= 'thumbnail_'.$last_image_number.'.'.$image-&gt;getClientOriginalExtension();
    $image-&gt;move($thumbs_path , $thumb_name);
    $thumbnails [] = '/'.$ad-&gt;ad_id.'/thumbnails/'.$thumb_name;
    $ad-&gt;thumbnails = implode('||',$thumbnails);
    $ad-&gt;save();


    // dd($image_name);
    return response()-&gt;json(['success'=&gt;true]);
</code></pre>
