bulk upload of user pictures

bulk upload of user pictures

by josephine wilson -
Number of replies: 24
I'm trying this out with a practice Moodle 1.9 site - I am in the 'upload user pictures' section - I know I need to upload a zipped file and the photos should have the same name as my users (plus jpg) - but nothing seems to be happening - I wait awhile then get 'users updated 0, errors 0' Any ideas please?
Average of ratings: -
In reply to josephine wilson

Re: bulk upload of user pictures

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Josephine - Perhaps you could email a zip file with some images. I've not had any problems with this during testing but we could have missed something. Peace - Anthony
In reply to Anthony Borrow

Re: bulk upload of user pictures

by josephine wilson -
Hi Anthony - I am only practising with a handful of users and images- as you'll see smile - here's the zipped file smile
In reply to josephine wilson

Re: bulk upload of user pictures

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Aha! Now I see the problem. Your zip file has a subdirectory, and the picture files are inside it. The current code expects the picture files not to be in subdirectories at all, so it doesn't find any picture files to process.

I'll see if we can modify the code to handle this situation in an easy way.

Thanks a lot for bringing this up! big grin

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well, it was easier than I expected, so here is a modified uploadpicture.php that handles picture files in subdirectories as well.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

And a patch file in case anyone is interested.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by josephine wilson -
Well - thanks so much smile Except.. it now appears to work fine - it thinks it's worked! But when I go to look at the user pictures the yellow smiley is no more but there is a red x instead of their new pictures.   Have I missed something out? So near yet so far smile
In reply to josephine wilson

Re: bulk upload of user pictures

by Steve Hyndman -

A shot in the dark here, but have you tried zipping your images so they will not be in a subdirectory and uploading them that way? To do this:

1. Go inside your directory until you see all your images

2. Select all your images (Ctrl+A)

3. Point to any highlighted image and right click

4. Select "Send to", then "Compressed (zipped) folder"

Now you will have a zip file that will have the name of one of your images, but the zip will contain all your images without them being in a subdirectory. Upload that and be sure to select to overwrite existing pictures.

Steve

In reply to Steve Hyndman

Re: bulk upload of user pictures

by josephine wilson -
Hi thanks Steve. I have looked further and to  be honest I think it is an issue with my photos not showing up because I've made an error somewhere in setting up Moodle 1.9 (first time I have done an install myself) I tried simply uploading one in the usual way and that didn't show either - so in this instance; it must be me! However, glad to have helped develop the upload picture facility on the way smile
In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by OKonmah Henry -

please, i have problem uploading bulk pictures to moodle 2.9.2 and i am not uploading from a sub-directory folder. i need help please.

In reply to OKonmah Henry

Re: bulk upload of user pictures

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I know nothing of the issue you are reporting, but I do know that "problem uploading"  is insufficient information to make it easy to help you.

In reply to Marcus Green

Re: bulk upload of user pictures

by OKonmah Henry -

so, what help are you suggesting i try, i truly need help to upload bulk pictures.

In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by Enrique Ruiz -
I also have problems trying to upload images for all my users.
I had the zip file but i got this error;
"User with a 'username' value of '' does not exist. Skipping.
Cannot save picture for user 8b1. Check original picture file."

8b1 is the username. and I have a username with that name.

do you have any ideas?

thanks Enrique

In reply to Enrique Ruiz

Re: bulk upload of user pictures

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Enrique - What is the image format. Could you send me a sample zip file to see what is happening? Peace - Anthony
In reply to Enrique Ruiz

Re: bulk upload of user pictures

by Karthick B -
Hi,
i am also having the same problem like "Cannot save picture for user abc . Check original picture file."

i am having moodle 1.9 installed both in my server and in my local machines.

i installed Linux in my server and xampp in the local which is having XP as OS.

now, the image uploading functionality is working fine in local and its throwing the above said error in my server.

is this error related with Linux, cause its working in windows environment and not in Linux..
i have attached a sample zip file here.

Any idea about this?


In reply to Karthick B

Re: bulk upload of user pictures

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This message appears only if:

  • Moodle can't create the user directory to hold the user picture
  • Moodle can't deal with the image file. 99% of the time this is due to a missing or misconfigured PHP GD extension.

Could you check that you have the PHP GD extension installed and enabled, and that you've set the correct GD version under Administration >> Server >> System Paths?

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by Karthick B -
hi,

You are absolutely correct. i already figured that out and changed the settings and its all working fine now..

Thanks for your reply..

What i do is

1. Checked whether my server holds the correct GD Version(needs GD 2.x).

2. Logged in as admin, go to

site administration > server > system paths and

set the gd version "GD 2.x installed".

That's it, i am now able to upload user pictures from admin...

Cheers
Karthick B




In reply to Karthick B

Re: bulk upload of user pictures

by Germán Salgar -
Muchas gracias por estas instrucciones. Llevaba tiempo tratando de descifrar porqué Moodle no podía crear las fotos de los participantes.

Tengo la versión 1.9.5 y en el perfil de usuario no me aparecía la opción de subir las fotos. Ahora ya me aparece la opción.
MUCHAS GRACIAS IÑAKY Y KARTHICK.
In reply to josephine wilson

Re: bulk upload of user pictures

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Josephine,

I developed that part of the code, so maybe I could help you diagnose what's going on.

The code has extensive status messages telling the admin the progress of the upload, so it's a bit strange that you don't have any of those messages. Anyway, we can add some additional debugging statements and see what gets out wink

Can you edit .../moodle/admin/uploadpicture.php and add the additional lines marked below?

First code snippet (around line 97) } else { $num_files_or_dirs = 0; // <<--- Add this line here $num_files = 0; // <<--- Add this line here while (false !== ($item = readdir($handle))) { $num_files_or_dirs++; // <<--- Add this line here echo '

Processing file or directory called ' . $item . "\n
"; // <<--- Add this line here if($item != '.' && $item != '..' && is_file($zipdir.'/'.$item)) { $num_files++; // <<--- Add this line here // Add additional checks on the filenames, as they are user // controlled and we don't want to open any security holes.

Second code snippet (around line 152):

notify(get_string('usersupdated', 'admin') . ": $usersupdated"); notify(get_string('errors', 'admin') . ": $userserrors"); echo '

Number of processed files or directories: ' . $num_files_or_dirs . "\n
"; // <<--- Add this line here echo '
Number of processed files: ' . $num_files . "\n
"; // <<--- Add this line here echo '';

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hummm, the code filter has completely munged the second code snippet, so here it goes again:

notify(get_string('usersupdated', 'admin') . ": $usersupdated"); notify(get_string('errors', 'admin') . ": $userserrors"); echo '

Number of processed files/directories: ' . $num_files_or_dirs . "\n
"; // <<--- Add this line here echo '
Number of processed files: ' . $num_files . "\n
"; // <<--- Add this line here echo '';

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by josephine wilson -
Hi Inaki - I have tried a couple of times to add your code to the appropriate file - but, not being very good at reading code I am not sure I am putting the snippets in the absolutely right place as I keep getting code error messages when I refresh. Here is my file for what it's worth - this IS the correct file I take it?
In reply to josephine wilson

Re: bulk upload of user pictures

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes, that is the file. But it seems the filters at Moodle.org keep destroying the second snippet. So here goes a modified file so you can directly use it (keep a clean copy of the original file, just in case).

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: bulk upload of user pictures

by Mr. Marc -

 Iñaki Arenaza is there a way that there is an updated version that will work with 2.2.1?  I would like to do the same for our newer moodle install?