0

I have a website made with Laravel and recently i have uploaded it on cPanel and now i have some problems; First problem is that in localhost i can save images in public/images from website and delete them but on cPanel no longer i could upload images.

Second issue is that i have removed all the images in cPanel but still my website loads that old images.When i go to image url directory there is nothing! i don't know how is it possible.

This is the code i used to save images:

$image = $request->file("image");
    $new_name = "image" . "_" . $lesson->id . "." . $image->getClientOriginalExtension();

    $image->move(public_path('images/lessons'), $new_name);

And the code for show images:

src="{{asset('images/lessons/image_'.$lesson->id.".png")}}"

This is my local folder :

Local folder

Below you can find my public_html folder :

public_html folder

Amira Bedhiafi
  • 6,070
  • 6
  • 17
  • 48
  • 1
    First problem is probably a permission problem, check PHP error log. Second problem is probably due to some caching (browser or server) – HTMHell Sep 30 '18 at 18:15
  • @HtmHell i have deleted browser cache and also tried on new devices but still loads that images! –  Sep 30 '18 at 18:24
  • can you check the image exist in your respective folder – Gurpal singh Sep 30 '18 at 18:51

2 Answers2

0

I have a website made with Laravel and recently i have uploaded it on cPanel and now i have some problems; First problem is that in localhost i can save images in public/images from website and delete them but on cPanel no longer i could upload images.

Could you explain this a little bit more detailed? Thank you.

Second issue is that i have removed all the images in cPanel but still my website loads that old images.When i go to image url directory there is nothing! i don't know how is it possible.

Sounds like Cache. Have you tried to empty your browser cache after deleting the images on your server? If they are gone, it was the Cache. A cache will/can expire after some amount of time, so that should not be an issue.

If you want to disable caching while debugging you can turn it off in your developer console. See this answer: Disabling Chrome cache for website development

I hope this helps.

wsdt
  • 85
  • 8
  • I have tried on new devices and also on phone using APIs, still loads that images. One strange thing is that when i removed all the files on cpanel and uploaded them again, one image is shown on two places with two different names! –  Sep 30 '18 at 18:26
  • For first problem; one new public folder in local folder(that contains every thing except main public folder) is automatically generated and inside it the images folder. Images are saved there –  Sep 30 '18 at 18:37
0

Try renaming the image, and after you rename, access the link for the renamed image ( using the new name ).

ie. www.xyz.com/image2.png

And then try delete.