Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

salvador98's avatar

url

hi. i use ck editor with laravel file manager for send post.. when i upload image or file , file or image url is https://aa.com/img.jpg now i want change site url to bb.com but my file is aa.com .. this is problem..

0 likes
4 replies
jlrdw's avatar

And along those lines, it is better just to store the file name, and build url to view it.

rover.jpg

Not

https://somesite/myimages/rover.jpg

use helper to build myimages/rover.jpg or whatever url it is.

Cronix's avatar

@jlrdw I totally agree with that. Don't store domain specific urls in the database. You never know when you will change domains, or directories that the images are stored, etc. Just store the filename and output it in html how you need it. <img src="//img/{{ $row->imagename }}">

Better yet, make a config file with the paths to different image types.

config/imagelocations.php

<?php

return [
    'profiles' => '//img/profiles/',
    'avatars' => '//img/avatars/'
];
<img src="{{ config('imagelocations.profiles')}}{{ $row->imagename }}">

Then if you ever change directories, you just have to update the single place in the config file and it will change them everywhere automatically.

Please or to participate in this conversation.