PDF and image files corrupted when downloaded from Moodle

PDF and image files corrupted when downloaded from Moodle

by Lars Lyngsøe Højberg -
Number of replies: 5

Hi all


I’m having a hard time getting my pdf-files (and images) working agter site migration.


These are the solutions I tried

Purge cache 

Re-uploaded in binary mode

Check webroot

Permissions on folders

and a lot of threads in here


When I am trying to view eg pdf’s downloaded from Moodle they are corrupt with a mix of normal letters, odd symbols large letters etc.

When I create a new fil everything is normal and if I download the old file through ftp from filedir on moodledata it also looks normal. Its only when I try to view the file through Moodle the errors come.


Please help.


/Lars

Average of ratings: -
In reply to Lars Lyngsøe Højberg

Re: PDF and image files corrupted when downloaded from Moodle

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Try downloading a file, then look at it with a suitable editor that can display the raw contents of binary files (you will probably find that a text editor such as notepad2 will do the job - or you could use a specialist tool like a hex editor if you prefer).

Chances are quite high that there is a PHP warning message (in text or HTML) at the beginning of the file, which is causing it to be corrupt - seeing the warning will help you figure out what's wrong with your Moodle.

--sam



In reply to sam marshall

Ang: Re: PDF and image files corrupted when downloaded from Moodle

by Lars Lyngsøe Højberg -

Hi Sam


I just tried and no php-errors there.

Beginning of file:

%PDF-1.6%âãÏÓ

55 0 obj<</Linearized 1/L 12258589/O 57/E 3633322/N 8/T 12258173/H [ 515 343]>>endobj           78 0 obj<</DecodeParms<</Columns 5/Predictor 12>>/Filter/FlateDecode/ID[<83C9FE83AA39495E85B4FB4E7CD2F129><04A57CBF867B462EB14200D62EB655F3>]/Index[55 41]/Info 54 0 R/Length 110/Prev 12258174/Root 56 0 R/Size 96/Type/XRef/W[1 3 1]>>stream

hÞbbd```b``ö‘õ ’ID²IH–`vX\,rL®CȲ< “Ý`rˆŒ: "ãÁlž`½?$#·#˜}D

>>


In the end I can't see the EOF when downloading via Moodle but not via ftp? 

When trying to view a .png-file for example i get an image with a lot of colorful lines - but not when I download via ftp

Regards

/Lars

In reply to Lars Lyngsøe Højberg

Re: Ang: Re: PDF and image files corrupted when downloaded from Moodle

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Sorry, I'm out of ideas then! sad

In general, if files get corrupted anywhere it's sometimes something to do with line feeds getting converted but I don't really see how that would happen...

--sam

In reply to sam marshall

Ang: Re: Ang: Re: PDF and image files corrupted when downloaded from Moodle

by Lars Lyngsøe Højberg -

Hi Sam

Actually I compared two files one downloaded via ftp and one via moodle. The one over ftp is working perfectly and the one via Moodle contains errors.

The comparison showed that the one via Moodle lacked EOL signs ^M

Does this tell you anything?

Thanks

/Lars

In reply to sam marshall

Ang: Re: Ang: Re: PDF and image files corrupted when downloaded from Moodle

by Lars Lyngsøe Højberg -

Hi Sam

I actually ended up regenerating content from scratch - but thank you for your good advice.


/Lars