Welcome Guest, Not a member yet? Register   Sign In
Images and css files not loading on live server
#1

I am using the latest ci4 and all looks fine on local host but on web server the images are not appearing. 
I have put images into into public/images and css into public/css.
All config files look fine and everything else including database is working.
I used the html helper to construct link and img tags as well as doing it manually for comparison but neither work on the web server however everything is working correctly on the local server?
Any help would be appreciated.
Reply
#2

(05-14-2020, 06:10 AM)Tony.Green Wrote: I am using the latest ci4 and all looks fine on local host but on web server the images are not appearing. 
I have put images into into public/images and css into public/css.
All config files look fine and everything else including database is working.
I used the html helper to construct link and img tags as well as doing it manually for comparison but neither work on the web server however everything is working correctly on the local server?
Any help would be appreciated.

I have the images working now but I have not resolved the css file issue yet.

Turns out that I chose a png file for my testing that was 74k in size? When I used a jpg or gif file it worked just fine and when I tried a smaller png file it also worked. So I am intrigued about what is causing the image display problem?
Any ideas anyone?
I can work around this for now but I am hoping that this will not be a show stopper further down the line?

Just for anyone else that has to try and fix something like this I have found that having my images in an images folder under public references the images just fine using any of these examples:

<img src="images/someimage.png" />

<?php echo img('images/someimage.gif'); ?>
(of course with this you will have to have loaded the helper('html') in your controller before echoing the view as it is using the img function from the ci helper)

<img src="<?php echo base_url('images/someimage.jpg'); ?>
Reply
#3

Why not try and share example codes
Reply
#4

(05-14-2020, 09:35 AM)seunex Wrote: Why not try and share example codes
As this is my first post please forgive me if I have not submitted it correctly.
The code I am using is as supplied during the install with the news code added in as per the examples provided in the manual therefore adding it here did not seem relevant.
This is my second reply to this post, the first one is still in moderation.
My first reply does discuss that I have resolved the image display problem and how I resolved it to help others.
 I am still struggling to understand what is stopping my css from working on the live server especially when it is working fine on my local server?
This would seem to indicate that there is a setting wrong somewhere but after a full day of searching and trying everything I can think of I am still unable to get the css working.
Any helpful suggestions would be warmly received.
Thank you.
Reply
#5

Hi, can you provide some details on how you are linking to your CSS files?

And how your domain look on your development machine and live, when accessing your application. But please mask the live adress like this:
example.com or example.com/public/
Reply
#6

Thank you for replying.
Probably simpler to go to my site online and view the source code: https://ci4test.tgapps.co.uk
Also: https://ci4test.tgapps.co.uk/news

Would that be clearer?
Reply
#7

Either your .css file are broken or your server, as it's sending it as text/html instead of text/css. Same with your images, being served as text/html.
Reply
#8

Thanks for your reply.
Can I ask how you managed to figure that out and have you any idea what would make this happen?
Reply
#9

Hi, I used the Network tab in Google Chrome ( CTRL + Shift + I ).

I'm afraid not, you need to Google your server software; e.g. "IIS images text/html".

Attached Files Thumbnail(s)
   
Reply
#10

jreklund thanks for your guidance with this problem.
I have now found a resolution albeit not ideal.
On my live web server account I am running with php 5.6 set to the current php version and I was using this line in my .htaccess file located in the project root:
SetHandler application/x-httpd-ea-php73
This was originally used in my wordpress site on the live server to allow it to run with the newer php version and so I thought that it would also work for Codeigniter 4. Howwever this was the cause of me chasing around for 2 days trying to track down the problem!
I then thought that maybe I could get away with making php7.3 the current php version on the web server and using a similar line in each of the php5.6 codeigniter2/3 web apps .htaccess like this:
SetHandler application/x-httpd-ea-php56
to overcome the problem. Unfortunately all that did was shift the problem to all of the php5.6 codeigniter web apps!!
Not sure what it is about using this SetHandler on the web server that causes the issue but obviously it does not provide a 100% php version for some reason.
So it looks like all I can do for now is work locally to learn Codeigniter 4 and then rewrite all of my old codeigniter 2/3 web apps and then endure some downtime while I change the server back to php 7 and attempt to deploy them in a live environment - not what I had hoped to do at all.
If anything I have said here rings any alarm bells or you can think of anyway other way of working with two different php versions on the live server then please share your thoughts.
Thanks in advance.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB