Installing and upgrading help

Photos are not shown

 
Picture of Leah Lever
Photos are not shown
 

Hello everybody
I have migrated my moodle website from my local host to a web server
Everything seemed to work fine but then i found a problem
I had created a quiz with multiple choice questions
The questions and the answers are pictures
None of those pictures are shown on the webserver site
I have transfered all the moodle data folder to the new server but the photos are not shown

Can you tell me what I can do to resolve it ???

Thank you

My moodle version is Moodle 3.5.2 (Build: 20180910), mysql version on the web server is 5.6 and php version is 7.x

See what I mean below :

This is the quiz question on my local host :

And this is the quiz question on the webserver :

The pictures are gone

 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

Suggest first one make a backup of what you have on server ... especially an sql dump of the database for your Moodle .... then ponder the following:

Did you miss a step after getting files into place on true server from local host ... to see the site one had to edit config.php file and change variables to locations/true server setup, but did you also do the step on 'search and replace'?

Any file uploaded to localhost, had a path using localhost in it ... recorded in tables of DB ... search and replace is supposed to find all references in all tables for http://localhost:8080 (or whatever that was) to https://trueserver/ (whatever your server's FQDN is).

https://docs.moodle.org/35/en/Moodle_migration

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 

Yes Ken, I did the Search and replace step and I still dont see the photos

The path is correct but the photos are not shown
Do you have any idea why ???
 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

Could make lots of guesses ... maybe one of those right .... maybe none.

So how about you do this ... turn on debugging.   Go to a quiz where images aren't showing and see if debug says anything.  Copy  and paste the text of debug to a response here in this thread.

The other place ... web server error logs.  Would look for errors related to not being able to find files - 404's - or access denieds - 403's.

One guess ... 'path' is deceiving as it's really meta data built from DB records which point to obscured files in moodledata/filedir/ ... nothing in there by humanly recognizable names.

So since we were migrating from local to server,  ownerships/permissions on not only moodledata but filedir and all subdirectories/files contained there in are correct for new environment?

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 

Hey Ken I forgot to mention that the new site is https

Do you think that could be the issue ??


 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

Have you run https://yourserver/admin/tool/httpsreplace/ ?

Other than that ... again ... debug on ... check error logs of web service ... check ownership/permissions recursively on moodledata/filedir/

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 

yes dear Ken, I did run https replace, but nothing changed with the uploaded photos. Only when I go through quiz editor and reupload and replace the images, then I can see them. Unfortunately I have to replace all the images one by one. Thank you so much for your help ...

 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

When you right-click/crtl click on one of the images to see it's info/URL, what do you see?

And there is nothing in web service error logs nor debug output?    Hmmmmm ...

Could be a bug.  If reported as a bug, the difficulty is reporter has to provide a way to replicate the issue and to be exact, one would have to provide an SQL dump, archive of code, and archive of moodledata for researchers to have *exactly* what was used.   And, they might have to acquire an account where you are hosted to test *exactly* .... don't think that's gonna happen! ;)

But, this also might not be a bug (or one that will not be fixed) as site was developed with localhost and migrated that entire site to server - *not the same environment*.

Personal opinion .... I've never used localhost development versions to develop entire site and then transfer that entire localhost site to server.   Environment is certainly NOT the same.

I know there are at least two posters that say it works for them ... but, not for all ... your issues proof of that?

One can setup a site being developed where no one can login to it ... nothing shows on front page, etc. while developing.   When done developing, then 'open access' as per preferences.

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 
The images are not stored as images, moodle code removes their extensions. But I have noticed when I add the image extension in one of those files on my local server, the file opens as an image normally. But when I do the same with the files stored on the web server, it wont open. Can you explain this ??
 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

When one uploads a file to moodle via it's interface, let's say it's an image ... called 'thanks.png' ... the file isn't stored by a humanly recognizable file name ... like thanks.png .. but as meta data in mdl_files table:

in that table there is a column for contenthash ...

Looks like:

ca22ce3d03bda9c6b25ed15b58701226dd52b0c8

That becomes the file when stored in moodledata/filedir/

It is located in moodledata/filedir/ca/22/ca22ce3d03bda9c6b25ed15b58701226dd52b0c8

The meta data in mdl_files table associated with that row of info for a file has a column for filename and in that column one sees the real name of the file: thanks.png

There is also a column in the mdl_files table for that row for mimetype.  The above example has "image/png" for the 'thanks.png' file.  That info is needed by browsers so any browser knows what to do with the file.

Here's what a direct mysql query looks like for the 'thanks.png' graphic file to locate it in the DB:

mysql> select contenthash,filename,mimetype,component from mdl_files where filename = 'thanks.png';
+------------------------------------------+------------+-----------+--------------+
| contenthash                              | filename   | mimetype  | component    |
+------------------------------------------+------------+-----------+--------------+
| ca22ce3d03bda9c6b25ed15b58701226dd52b0c8 | thanks.png | image/png | mod_resource |


from the server via ssh and located in moodledata/filedir/ a find ...

[root@sos filedir]# find ./ -name ca22ce3d03bda9c6b25ed15b58701226dd52b0c8
./ca/22/ca22ce3d03bda9c6b25ed15b58701226dd52b0c8

One can see the contenthash as in db is the filename as stored on server.

and using another command to check file type:

[root@sos filedir]# file -b ./ca/22/ca22ce3d03bda9c6b25ed15b58701226dd52b0c8
PNG image data, 426 x 294, 8-bit/color RGB, non-interlaced

one can see it's PNG data, it's demensions, and other characteristics that PNG file has.

Now on your local host ... one can cheat ... add an extension to a file like that found on local host and your local host machine will display.   Matter of fact, on Mac's, one could actually double click on the file (this one: /moodledata/filedir/ca/22/ca22ce3d03bda9c6b25ed15b58701226dd52b0c8) and the Mac is 'smart enough' to read the file header and open it in Preview.   PC's ... think they would need a filename extension.

No, I cannot explain what happened when entire site was migrated from local host to true server.

My experience has been migrating from server to server and can say that as long as I have completed all the steps have had no issues like you've been experiencing.

Do you have phpmyadmin or something where you could make a query of the DB on the server for the file name of one of those images in the quiz?

You could make the same query using PHPMyAdmin changing only the filename:

select contenthash,filename,mimetype,component from mdl_files where filename = 'CHANGETHIS'

Let's see what your DB has.

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

When one uploads a file to moodle via it's interface, let's say it's an image ... called 'thanks.png' ... the file isn't stored by a humanly recognizable file name ... like thanks.png .. but as meta data in mdl_files table:

in that table there is a column for contenthash ...

Looks like:

ca22ce3d03bda9c6b25ed15b58701226dd52b0c8

That becomes the file when stored in moodledata/filedir/

It is located in moodledata/filedir/ca/22/ca22ce3d03bda9c6b25ed15b58701226dd52b0c8

The meta data in mdl_files table associated with that row of info for a file has a column for filename and in that column one sees the real name of the file: thanks.png

There is also a column in the mdl_files table for that row for mimetype.  The above example has "image/png" for the 'thanks.png' file.  That info is needed by browsers so any browser knows what to do with the file.

Here's what a direct mysql query looks like for the 'thanks.png' graphic file to locate it in the DB:

mysql> select contenthash,filename,mimetype,component from mdl_files where filename = 'thanks.png';
+------------------------------------------+------------+-----------+--------------+
| contenthash                              | filename   | mimetype  | component    |
+------------------------------------------+------------+-----------+--------------+
| ca22ce3d03bda9c6b25ed15b58701226dd52b0c8 | thanks.png | image/png | mod_resource |


from the server via ssh and located in moodledata/filedir/ a find ...

[root@sos filedir]# find ./ -name ca22ce3d03bda9c6b25ed15b58701226dd52b0c8
./ca/22/ca22ce3d03bda9c6b25ed15b58701226dd52b0c8

One can see the contenthash as in db is the filename as stored on server.

and using another command to check file type:

[root@sos filedir]# file -b ./ca/22/ca22ce3d03bda9c6b25ed15b58701226dd52b0c8
PNG image data, 426 x 294, 8-bit/color RGB, non-interlaced

one can see it's PNG data, it's demensions, and other characteristics that PNG file has.

Now on your local host ... one can cheat ... add an extension to a file like that found on local host and your local host machine will display.   Matter of fact, on Mac's, one could actually double click on the file (this one: /moodledata/filedir/ca/22/ca22ce3d03bda9c6b25ed15b58701226dd52b0c8) and the Mac is 'smart enough' to read the file header and open it in Preview.   PC's ... think they would need a filename extension.

No, I cannot explain what happened when entire site was migrated from local host to true server.

My experience has been migrating from server to server and can say that as long as I have completed all the steps have had no issues like you've been experiencing.

Do you have phpmyadmin or something where you could make a query of the DB on the server for the file name of one of those images in the quiz?

You could make the same query using PHPMyAdmin changing only the filename:

select contenthash,filename,mimetype,component from mdl_files where filename = 'CHANGETHIS'

Let's see what your DB has.

Also, have asked that you turn on debugging to see what it might have/say.   Have also asked that you check your servers web server logs ... error log in particular.   Please do.

Think one could drive themselves crazy trying to figure out things by comparing localhost to server ... so concentrate efforts now on the server.   That's where the problem is, right? smile

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

Have one *last* suggestion for you ...

make one full course backup on localhost.  Restore that backup to the server.   Errors on restore?   Quiz images show?

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 

yes Ken you saved me !!!!!!!!!!!!!

Thats the BEST SOLUTION !!!!!!!!!!!

IT WORKS PERFECT !!!!!!!!!!!!!!

I NEVER THOUGHT TO DO THAT AND ITS SO SIMPLE

YOU ARE THE BEST !!!!!!!!!!!!!!

THANK YOU SO MUCH !!!!!!!!!!!!!!!!!!

 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

HooRah!  Welcome.  Emma's suggestion was one I forgot, but you said you did that.

Hmmmm .... how about the cron job setup on server?  Cron/Task should have done something with cache by now.   Is cron job running?   How often?   Recommendation now a days is cron runs once every minute.   Can verify that Moodle's seem to run smoother when cron runs every minute.

And ... do learn how to turn on debugging as well as locating/viewing your server web service logs in the near future.

Now that you've got it working ... do a full site backup.   Now.  Don't put backups off ... do them on a regular basis and you will never regret the time spent doing them. smile    Also backup that course.

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 

OK Ken, thank you again

smile smile smile



 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 

well Ken, it looks this migration will never end

I have another issue now

The background image of my custom certificate is not loading

I re uploaded the image but still is not working

any suggestions ???

thank you in advance


 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

Sigh! .... is cron job running?   Prove it!

What are ownerships/permissions on moodledata/filedir/ ?  just don't say they are correct ... prove it!

Did you clear caches ... server ... + your browser.

Turn on debugging.  Check web server error logs.

'spirit of sharing', Ken

(probably should have started a new thread)


 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 
Its the SSL connection, it blocks the image and in the edit certificate mode is not loading
But fortunately, when I downloaded the certificate it works fine
Its difficult to edit the certificate though, without viewing the background image
You have to try many times for the correct position of the fields
Anyway it works
Thank you for the reply Ken
smile
 
Average of ratings: -
Picture of Ken Task
Re: Photos are not shown
Particularly helpful Moodlers

Glad it does work cause I have not a clue as to what this latest hickup is about .... ;)

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Emma Richardson
Re: Photos are not shown
Documentation writersParticularly helpful MoodlersPlugin developers

Did you delete out the cache?

 
Average of ratings: -
Picture of Leah Lever
Re: Photos are not shown
 

Yes Emma I did, but the photos were not shown

The best solution is restore the course from the old server

It worked

Thank you for asking

smile


 
Average of ratings: -