0

I am creating a tool in which user uploads an image or gives an external link of image. so I am storing that image url in my database. if a user uploads image then I am storing full path of the file eg:

C:\xampp\htdocs\project\public\upload/1571149288.jpg

and if the user is giving me an image url

eg:

https://example.com/images/ask1571149288e.jpg. 

I am storing this full path, in next screen i need to display last three images that user uploaded, in any using db stored path,

Contoller

$previousUpload = DB::table('background_trimmer')->where('user_id',1)->limit(3)->orderBy('id', 'desc')->get();

    return view('user.clippingMagic.upload', array('previousUpload'=>$previousUpload));

Blade View

    <div id="recent-images" class="mt-3">
     @foreach ($previousUpload as $recentImage)
         <div class="recentimages">
             <img src="..\{{$recentImage->image_title}}" alt="image recent" />        

        </div>
      </div>
 @endforeach
</div>

getting 404 for image and the image src is now => http://127.0.0.1:8000/C:\xampp\htdocs\New folder\marketermagic\public\upload/1571206254images.jpg

what i want it

C:\xampp\htdocs\New folder\marketermagic\public\upload/1571206254images.jpg

if i hit C:\xampp\htdocs\New folder\marketermagic\public\upload/1571206254images.jpg this url in a browser tab i have the image. as i have stored the full path of image so i dont need to have a base url any anthing to be added by laravel, it should take my url as it is. thanks for any help

  • no this does not resolve my problem and its not like mine as the answer u suggested – Ganesh chandra Oct 16 '19 at 07:09
  • You have to check [Laravel Displaying image from database](https://stackoverflow.com/questions/28563018/laravel-displaying-image-from-database) –  Oct 16 '19 at 07:12
  • I tried this one too, {{ asset('uploads/appsetting/' . $page->image) }} as i have full path so nothing to do with asset(); image could be a third party url – Ganesh chandra Oct 16 '19 at 07:15

1 Answers1

0

Case Study :

You have two options:

  1. User can upload image
  2. Or s/he can input external image link.
What you have to do :
  1. IF user upload image then make a public browsable url of you internal script. Like user upload abc.png image you should make a public browsable url of that image. Say how ? just add base url + upload folder path + image name very simple steps. Final output should look like this : http://example.com/YOUR_ASSETS_PATH/abc.png and store it to DB.

  2. IF user input external url just save it to DB.

VIEW: <img src="{{$recentImage->image_path}}" alt="image recent" />

Thats it !

Community
  • 1
  • 1
Rashedul Islam Sagor
  • 1,943
  • 14
  • 20
  • as of now, I have stored 'C:\xampp\htdocs\New folder\marketermagic\public\upload/1571206254images.jpg' then it should display the image – Ganesh chandra Oct 16 '19 at 09:23