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

3
  • no this does not resolve my problem and its not like mine as the answer u suggested Commented Oct 16, 2019 at 7:09
  • You have to check Laravel Displaying image from database Commented Oct 16, 2019 at 7: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 Commented Oct 16, 2019 at 7:15

1 Answer 1

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 !

Sign up to request clarification or add additional context in comments.

1 Comment

as of now, I have stored 'C:\xampp\htdocs\New folder\marketermagic\public\upload/1571206254images.jpg' then it should display the image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.