Profile pictures

Profile pictures

โดย Eliyahu Mitterhoff -
Number of replies: 22
I just installed and I cannot up load my profile picture.
การประเมินโดยเฉลี่ย: -
In reply to Eliyahu Mitterhoff

Re: Profile pictures

โดย scott johnson -
There is a setting in one of the PHP.ini files that references the file php_gd2.dll
with a semi-colon before it. Remove the semicolon, restart the apache server for good measure and gd2 should be enabled in Moodle allowing you to upload jpg and gif pictures. I had the same trouble but noone seemed to know the answer - here or in the area the previous person directed you to. I found myself reading round in loops and getting so frustrated. Good luck.

การประเมินโดยเฉลี่ย: -
In reply to Eliyahu Mitterhoff

Re: Profile pictures

โดย Michael Feldmann -

For me, it worked out by changing the file attributes of the file.php and the config.php in the moodle root directory to 644 using the FileZilla FTP client. I came about this because I kept receiving the below error message while trying to upload images into user profiles as an administrator:

>>>>>

Warning: main(config.php) [function.main]: failed to open stream: Permission denied in home/www/doc/.../moodle/file.php on line 9

Fatal error: main() [function.require]: Failed opening required 'config.php' (include_path='.:/usr/local/lib/php:/usr/local/php/lib/php') in /home/www/doc/.../moodle/file.php on line 9

<<<<<

การประเมินโดยเฉลี่ย: -
In reply to Eliyahu Mitterhoff

Re: Profile pictures

โดย Norman Rockwell -
I can't see any uploaded images on my profile. I'm on moodle 1.8.3+ and all profile images that are uploaded appear as broken graphics. I know the images are there and correct but moodle can't display them correctly.

I am just about at the end of my rope. Everything says I have gd installed enabled and up to date.

php-gd.i386 5.1.6-1.6 installed

gd

GD Support enabled
GD Version bundled (2.0.28 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.10
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

GD 2.x is installed is my selected version in the drop down.

I've turned off slash arguments and still no luck

Any image referenced like this:
http://area-forum.com/courses/user/pix.php?file=/3/f1.jpg

Displays as a broken image in IE and binary code in firefox.

Please help.
การประเมินโดยเฉลี่ย: -
In reply to Norman Rockwell

Re: Profile pictures

โดย Richard Enison -
NR,

It's good to know you're still alive at 113!

Seriously, I have 1.8.3 on my computer and your URL doesn't compute:
  1. There is no courses folder (directory); there is a course folder, but it has not user subfolder.
  2. The closest thing to your URL that makes sense on my site as far as I can tell is user/pix.php/2/f1.png, which gets redirected to pix/u/f1.png.
  3. In forums and every other context I can find on my site where my icon appears, the URL for it is user/view.php?id=2&course=1 (or 2), and when I display properties it shows its location as user/pix.php/2/f2.jpg
I'm surprised you are not getting a File not found or Object not found error. That's what I got when I tried your URL (with a different course/user number of course).

RLE
การประเมินโดยเฉลี่ย: -
In reply to Richard Enison

Re: Profile pictures

โดย Norman Rockwell -
Just a name friends, like being named Michael Bolton but not being able to sing. Although if I was related I wouldn't have to worry about moodle not showing a profile image wink

Any way RLE, I'm not sure I follow what you are saying, the url I posted is the direct link for the image:


That is what the page you talked about (user/view.php) uses as the img src, so I know the URL works fine, it is just the image that's not being pulled in correctly and you are correct I already have tried the slash arguments trick to no avail.

Thanks for the ideas though, please keep this coming I really want to solve this issue.
การประเมินโดยเฉลี่ย: -
In reply to Norman Rockwell

Re: Profile pictures

โดย Richard Enison -
NR,

It's hard to believe that Moodle's file system structure has changed so much within the same minor version (1.8.3), but Dick Viti has reported exactly the same problem with the same URL. Just for laughs, can you look at your folder structure with File Manager or something and confirm that your Moodle folder really does have a subfolder named courses, and that subfolder has a subfolder named user, containing a file pix.php? Because that's what your URL implies. Anyway, it's not the URL I get when I right click on the image and click Properties. And as I said, when I type a URL like yours, with appropriate course number/user number of course, in Firefox I get Object not found.

RLE
การประเมินโดยเฉลี่ย: -
In reply to Richard Enison

Re: Profile pictures

โดย Norman Rockwell -
RLE,
Thanks for the continued help. The problem isn't that pix.php can't be found or even that the images can't be found. Perhaps what is confusing you is the fact that dirroot is set to:
/var/www/html/area-forum/courses

And my dataroot lives here:
/var/moodle_uploads

When I load this url in IE:


I get a broken image. When I right click that and go to properties I get the same url. Now in firefox it behaves completely different in that what you'll see is the binary code when you view source, as if you tried to edit the jpg in VI or Notepad.

I know the images are correct in dataroot because I can create a symlink to them from dirroot and view them in a browser. But when I try to view them via pix.php they get trashed.

Does that make it more confusing or help clear up what the problem is?

I don't know what url you're trying to type but I don't imagine you'll ever find one to work. If you go to this page, you'll see a post by DV (whos my boss) and there you'll see that his profile image doesn't show up next to New Appraisal Exam Prep.
http://area-forum.com/courses/

Thanks
การประเมินโดยเฉลี่ย: -
In reply to Norman Rockwell

Re: Profile pictures

โดย Richard Enison -
NR,

I see. What you have told me is that your Moodle folder is the one called courses, but your web document root is the parent folder of that, which is why you include courses in the URL. That explains a lot. So what you are really accessing is user/pix.php relative to your main Moodle folder. That makes much more sense. Also, thx for the info on DV. That explains a lot, too.

Which means that the file structure of Moodle hasn't changed after all. When I tried to access user/pix.php?file=/2/f1.jpg on my site, it redirected to pix/u/f1.png, which displayed just fine. So it didn't go to the Moodle data folder at all for that image. It went to pix/u relative to my main Moodle folder. Which means that it must have copied it there at some point. Well, in my case, it gave me the default smiley face because I never uploaded an image for my profile in my own site as I did for moodle.org (needless to say). I'll try changing my profile in my own Moodle and get back to you.

RLE
การประเมินโดยเฉลี่ย: -
In reply to Richard Enison

Re: Profile pictures

โดย Richard Enison -
NR,

OK. I have run my test, which took several tries until I realized I had to do a reload of the web page to see the new image, and I have done some more research in the PHP source code of Moodle. Here's what I found.

When I updated my profile with a new image, it ended up in a couple of places, both under the data folder. It turns out that pix.php only redirects to pix/u as a last resort, if it doesn't find it under the data folder.

So here is my question to you: when you use your symlink to the image file under the data folder, exactly what pathname does that symlink point to? I'm guessing /var/moodle_uploads/user/0/3/f1.jpg.

Hang in there. We're almost at the point of fixing the problem, but first we need to find out what's causing it!

RLE
การประเมินโดยเฉลี่ย: -
In reply to Richard Enison

Re: Profile pictures

โดย Norman Rockwell -
RLE,
Thank you for running your tests, sounds like it worked for you and you found the same thing out about the code that I did.

The symlink actually just points to the directory that contains the image, here it is:
lrwxrwxrwx 1 root root 28 Dec 29 13:27 testme -> /var/moodle_uploads/user/0/3

Keep in mind that moodle doesn't know about the symlink just the dataroot.

I really appreciate your continued support on this, let me know what else I can tell you about the server or any other processes.

Thanks
NR


การประเมินโดยเฉลี่ย: -
In reply to Norman Rockwell

Re: Profile pictures

โดย Richard Enison -
NR,

Another thing I learned from your previous post is that your server is not a Windows box. The pathnames you mentioned are Unix-like, probably Linux. This suggests that your web server is not IIS, probably Apache. Assuming this, I would like to know:
  1. Is the server your own (your employer's) or are you using a commercial web host?
  2. If you have you own server, could you attach a copy of your httpd.conf file? Pls don't paste it into the post as it is probably too long for that (see the Post Length section of http://docs.moodle.org/en/Forum_posting).
  3. If you are using a commercial host, I would like to see the contents of any .htaccess files you are using, especially in the main Moodle folder (courses) and its subfolder user, as well as the data folder (moodle_uploads) and any subfolders. If you have .htaccess files I would like to see them even if it is your server.
RLE
การประเมินโดยเฉลี่ย: -
In reply to Richard Enison

Re: Profile pictures

โดย Norman Rockwell -
RLE,
Correct it is our own server. Its a Fedora Core 5, Apache 2.2.2, PHP 5.1.6 box and GD 2.0.28. We've been looking for a reason to move to Centos or Ubuntu and maybe this is a good reason to upgrade. I'm building another machine (probably Centos) here to test on as well.

There are no .htaccess files.

I'll attach the httpd.conf file and include the contents of my php.conf file inside of the conf.d directory.

conf.d/php.conf:
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#

LoadModule php5_module modules/libphp5.so

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps

AcceptPathInfo on

Thanks as usual.
การประเมินโดยเฉลี่ย: -
In reply to Norman Rockwell

Re: Profile pictures

โดย Richard Enison -
NR,

Things are starting to get weird. Last time I said we just need to find out what was causing the problem. Now it seems like we need to find out what it is that is being caused!

Here's the deal, in chronological order:
  1. After you said you get a binary dump of the jpg file when you use Firefox, I used Firefox to browse to the URL you posted, and got something different: the URL itself, as text.
  2. I have read your httpd.conf file and found some curious things in it, but they are probably not related to the image problem.
  3. The Apache problem I was looking for would be a failure of Apache to correctly identify the jpg file as a jpeg image file. In this case, it would send the wrong http header to the browser.
  4. So I used wget to access your URL and see what headers it is sending out. Here is what I got:

    HTTP/1.1 200 OK
    Date: Tue, 01 Jan 2008 05:53:21 GMT
    Server: Apache/2.2.2 (Fedora)
    X-Powered-By: PHP/5.1.6
    Last-Modified: Sat, 29 Dec 2007 18:25:34 GMT
    Content-Disposition: inline; filename=f1.jpg
    Cache-Control: max-age=86400
    Expires: Wed, 02 Jan 2008 05:53:21 GMT
    Pragma:
    Accept-Ranges: bytes
    Content-Length: 6553
    Connection: close
    Content-Type: image/jpeg

    So it correctly identified it as a jpeg image file.
  5. That leaves the other possibility, namely that Moodle messed up the content of the jpg file itself that it presented to Apache to send to the browser. Now wget had saved a copy of that content on my hard disk, so I looked at it to see what was in it. First I tried to open it as a picture and that failed. Then I opened it in Word as a text file (because I don't have anything like Norton Utilities' Disk Editor handy) and it seems that it begins with a line feed character followed by some text, namely:

    EMPTY ELSE (/var/moodle_uploads/user/0/3/f1.jpg) image/jpeg

    then some binary stuff and then some more text:

    CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90
Well, for all I know, it is normal for such text to be found near the beginning of a jpeg file, but I have reason to believe that a jpeg file should begin with hexadecimal ffd8. So maybe that's why it is not being recognized as a jpeg file.

Which leads to the question, where is the content of the file being mangled? It's probably in pix.php or one of the functions it calls, like send_file, which sends the contents of a file to the browser, and is defined in lib/filelib.php. But first, I want to see just how badly mangled it is. So could you pls either:
  1. post the URL of your symlink by which I can access the actual image, or
  2. attach a copy of that image file to your next post?
RLE
การประเมินโดยเฉลี่ย: -
In reply to Richard Enison

Re: Profile pictures

โดย Norman Rockwell -
RLE,
Sounds like we were heading down the same path. Some of what you saw on the wget was testing prints that I inserted into send file. I think I have the problem isolated to the readfile_chunked subroutine in filelib.php->send_file.

I have removed the prints that I was testing with so you should get the raw binary again. When I said FF displayed that, you actually have to go to view source to see it in FF.

The symlinked image is here:
Original image: http://area-forum.com/courses/user/pix.php/4/f1.jpg
Symlinked:

I'm going to do some more testing today but I won't mess with the moodle scripts.

Thanks for ALL of the help. Good idea on the wget I hadn't thought about trying that. When I tried the wget and tried to view the saved file in a browser I get the same result, broken in IE, url in FF (view source to see binary code).

การประเมินโดยเฉลี่ย: -
In reply to Norman Rockwell

Re: Profile pictures

โดย Richard Enison -
NR,

I had tried to do a View Source in FF. It was grayed out on the menus.

Thx for the URLs. I'll take a look at them. And look for my hex dump s/w. (I probably shouldn't trust MS Word for that.) If I can't find it, I'll recreate it (just a quick & dirty version of it). I might even use ye olde DOS debug utility!

Happy Gnu Year

RLE
การประเมินโดยเฉลี่ย: -
In reply to Norman Rockwell

Re: Profile pictures

โดย Richard Enison -
NR,

OK. I didn't need any hex-dump s/w, except one (you'll see what I mean). Here's what I found:
  1. I accessed the "original" image URL in IE and FF and got the same results as you, except that Page Source was grayed out on the View menu as before.
  2. I accessed the symlinked URL and saw the picture, which I saved as a file.
  3. I did the wget thing again. Same headers. Saved file.
  4. Looked at properties of both files. Same length: 4,185 bytes, consistent with the headers.
  5. Compared files byte by byte using DOS command fc /b.
  6. First thing I noticed: the real picture file begins ffd8, as I had thought.
  7. Second thing: the bad file begins with a line feed (hex 10), as I had found before with Word.
  8. Third thing: just about every byte position of the two files is different. Now that looks like a major mangle, maybe an encryption or total corruption, until I noticed the
  9. Fourth thing: the bad file is exactly the same as the good file, but shifted down by one byte, with a line feed inserted at the beginning. Of course, the last byte got shifted out and is lost.
Now, can you see in your study of the send_file function and the functions it calls, where this insertion of a line feed character (in unix/linux talk, that's a new line character, represented in PHP code as "\n") at the beginning of the file? Because I can't look for it in the code of Moodle on my machine, because the Moodle on my machine doesn't do that! So if you have trouble finding it, let me know, and maybe attach your filelib.php to your next post. I have attached the output of fc for your edification.

RLE
การประเมินโดยเฉลี่ย: -
In reply to Richard Enison

Re: Profile pictures

โดย Mauno Korpelainen -

Hi Richard and Norman,

one place to check in this kind of mysterious cases is either config.php or theme/area_cus/config.php

If you check source code in FF there are two empty lines at the beginning which usually means that config.php has empty rows or white spaces at the end ( after ?> ) or at the beginning (before <php? )

Every now and then files get some strange characters when they are edited with different text editors or saved with a different name (save as)...usually notepad or WordPad are the safest text editors but I have had some problems with files like moodlelib.php too when edited with notepad.

Attached one "clean" version of config.php (replace xxxx with correct data) and if the problem is in theme config.php try to copy standard theme config.php to another folder and edit it with WordPad and save (or rename but not save as)

การประเมินโดยเฉลี่ย: -
In reply to Mauno Korpelainen

Re: Profile pictures

โดย Richard Enison -
MK,

Thx. I had a hunch something subtle like that was going on. I was thinking, more specifically, along the lines of a PHP bug whereby the header or echo function was emitting an extra new line character or something like that. But NR had said his PHP version was 5.1.6, not 5.0.x, so I went back to looking for a bug in Moodle again. I was about to ask NR for the exact version and date from the first line of his filelib.php file when I saw your post.

RLE
การประเมินโดยเฉลี่ย: -
In reply to Mauno Korpelainen

Re: Profile pictures

โดย Norman Rockwell -
Hi MK and RLE,
That was it!!!!

I had an empty line after my close ?> in my main config.php. I deleted that and now the profile pictures are showing up.

Thank you so much MK and RLE.

Even though MK eventually had the solution I couldn't have gotten this far without all of your great help and effort RLE.

Huge thanks to both of you.
NR
การประเมินโดยเฉลี่ย: -
In reply to Norman Rockwell

Re: Profile pictures

โดย Rod Ward -

Norman,

This is a bit of a long shot, but you might try changing the Use Slash Arguments setting and see if that enables you to see the pictures.

You'll find it under Admin > Server > HTTP > Use Slash Arguments

Tick the box and save the setting, then see whether you get lucky.

Regards,

Rod Ward

PS::You're not the same Normal Rockwell that painted all those cute pictures on the covers of those old American magazines back in the 40's and 50's are ya?

การประเมินโดยเฉลี่ย: -
In reply to Rod Ward

Re: Profile pictures

โดย Richard Enison -
RW,

You need to read existing posts more carefully:
  1. NR said in his post that he had tried messing with slasharguments to no avail.
  2. The Norman Rockwell you describe is the one I was referring to when I jokingly said it was good to know he was still alive at 113. According to Wikipedia, he died in 1978.
RLE
การประเมินโดยเฉลี่ย: -