User Profile upload file

hprashi - June 8, 2007 - 11:42

hi,
I want users to be able to upload their resume when they register. I downloaded the profile module.. using which i was able to add additional fields when member is registering... but the upload file option is not there...
Can anyone please tell how to do this?

That's because there isn't one!

stevepurkiss - June 8, 2007 - 12:51

Hi,

I am trying to do the same thing! There is no file upload field for the profiles. I was looking into the taxonomy_fields module where you can attach different field types to content types, but don't think it will work here as profile isn't listed as a content type.

Another reply to a similar post (the only one I could find) says (http://drupal.org/node/59792) you can achieve it using the Content Construction Kit and Node Profile module (http://drupal.org/project/nodeprofile). I am looking into this at the moment. This module allows you to build profiles out of nodes, so you can put a file upload field in. I looked at the demo though and it looked a bit disjointed with the my account page.

Will report back on any success, in the mean time if anyone else has any ideas or who has done this before that would be most welcome!

http://www.open4.org/bio/steve-purkiss - view my online profile
http://www.open4.org/site_tour/quick_tour - free blogs and clubs with 100% AdSense revenue going to you!

Usernode, Nodeprofile

DesignWork - June 8, 2007 - 12:57

Hi

there is a solution for your problem, use usernode and nodeprofile or the bio.module. You have to make contenttypes out of your userprofiles. There are some examples around how to make it.

Dirk

Thanks but how do I get it in the register form?

stevepurkiss - June 8, 2007 - 13:30

Thanks Dirk, very helpful!

I installed the usernode profile and see it's fairly similar to the bio module except more generic.

My particular problem is that I want to show this field in the user registration form which I don't think the above solutions will help with. So I'm back to playing with user profile to see if that will do the job, unless I'm missing something obvious...

http://www.open4.org/bio/steve-purkiss - view my online profile
http://www.open4.org/site_tour/quick_tour - free blogs and clubs with 100% AdSense revenue going to you!

What you want to do...

DesignWork - June 8, 2007 - 14:02

hi open4.org

so maybe i missed something. What you want to do exactly? A user will register, than after entering name, email, password you want him todo what? Attaching a file? right!

Ok lets start from a scratch i would override the normal user.profile by usernode or bio. Than use pageroute and node family to make a easy way through the different steps he should do. Using an node type as profile makes it easy to attach a file, with node profile and node family you can even limit the may population to one etc.... And you can search all your user profiles via the core search witout any extra modules.

I know it sound a bit confusing but it works. www.freelens.ws/dirksway a testing site for a comunity.

Dirk

Think I'm getting there...

stevepurkiss - June 8, 2007 - 14:28

Kind of like that! It's for a jobs community site, so when people register I have added extra fields in the user profile which they can fill out when register (the pageroute module will be a great help here thanks!). The only field I have left is for the CV upload.

I'm currently half-following this tutorial:
http://shellmultimedia.com/tutorials/user-profiles

So I've created a new content type for user profile called uprofile, selected use as user profile node, and am just about to add a file field to it.

Getting there...

http://www.open4.org/bio/steve-purkiss - view my online profile
http://www.open4.org/site_tour/quick_tour - free blogs and clubs with 100% AdSense revenue going to you!

not using jobs/resume module

stevepurkiss - June 8, 2007 - 14:39

...and before you say "there's a jobs/resume" module - I know, but it doesn't do what I want (i.e. integrate into reg form) and has more than I need! I just need something that emails the site admin when a CV is uploaded as it has to be entered onto a third party system.

http://www.open4.org/bio/steve-purkiss - view my online profile
http://www.open4.org/site_tour/quick_tour - free blogs and clubs with 100% AdSense revenue going to you!

Woo - it works!

stevepurkiss - June 8, 2007 - 14:59

Thanks for all who pointed, I got it working in the end!

I used nodeprofile (which needs nodefamily and subform_element) and bits from this tutorial http://shellmultimedia.com/tutorials/user-profiles to create an extra field in the profile of file type which shows up in the registration form.

Feeling better now I know a little more about drupal than I did this morning, however glad I don't have to learn that one again ;)

http://www.open4.org/bio/steve-purkiss - view my online profile
http://www.open4.org/site_tour/quick_tour - free blogs and clubs with 100% AdSense revenue going to you!

God for drupal

DesignWork - June 8, 2007 - 18:03

Hi open4.org,

good that you found your way. Did you saw my aproach at freelens? Different one but it works.

Cheers and success

Dirk

hey open4 can u please tell

hprashi - June 8, 2007 - 18:14

hey open4 can u please tell me the steps followed to achieve it....

i couldnt follow :(

Step-by-step how to add a file upload field to user registration

stevepurkiss - June 9, 2007 - 13:54

DesignWork - I couldn't see how you did it on freelens. Couldn't see a register button, and /user/register didn't show up much - have you a link? I think your way may allow using pageroute, but I'm going to try it on the way I've done it first and if not work then I'll try your way!

hprashi - sure. I've just downloaded a fresh test install of drupal just to make sure I get it right ;)

Step-by-step how to add a file upload field to user registration

  1. Download and install the following modules (all for drupal 5)

    1. http://drupal.org/project/cck - Content Construction Kit, so you can add a file field to a type
    2. http://drupal.org/project/filefield - File Field - provides a generic file upload field for use with CCK
    3. http://drupal.org/project/nodeprofile - Node Profile, which creates user profiles as nodes so you can use them with the CCK
    4. http://drupal.org/project/nodefamily - Node Family, required by Node Profile and allows you to define relationships between nodes
    5. http://drupal.org/project/subform_element - Subform Element, required by Node Profile and allows you to create new forms from existing ones
    6. http://drupal.org/project/auto_nodetitle - Automatic Nodetitles, so user profile nodes have a title automatically created
    7. http://drupal.org/project/token - Token, used by Automatic Nodetitles to put the details of the user into the automatic nodetitle
  2. Create a new content type for the file upload field. Most of this is taken from the tutorial at http://shellmultimedia.com/tutorials/user-profiles but specialised for this tutorial

    1. Go to Administer -> Content Management -> Content Types and click "Add Content Type"
    2. Expand "Automatic title generation" link. Check the box and put in "[author-name]"
    3. Name: Resume (or whatever is appropriate for your use, their example used "User Profile" as they were extending a lot more than I was)
    4. Type: resume (this may cause conflicts if using the resume module)
    5. Description: Whatever you want
    6. Title field label: Leave as title as the user won't see it (unless you've elected to not use auto nodetitles)
    7. Body field label: Empty this out as we don't need the body
    8. Default options: Uncheck promoted to front page
    9. Maximum population: 1
    10. Check "Use this content type as a nodeprofile for users"
    11. Comments / Attachments / Contacting : Disable all of these (if they are there)
    12. Save content type
  3. Add the file field to the new content type

    1. In Administer -> Content Management -> Content Types (where you should be after the previous step), click "edit" on the content type you just created (Resume in this example)
    2. Click the option "Add field"
    3. Name the field something useful, "cv" in my case
    4. Select "file" for field type
    5. Click "create field"
    6. Add any file types you want to enable upload of. I added "rtf doc odt pdf" to the default txt option (Rich Text Format, Microsoft Doc format, OpenDocument Text, and Portable Document Format)
    7. Enter any help text you want to give the user (in my case "Upload your CV here"
    8. Leave required unchecked unless you require them to upload a CV when registering (IMHO a bad choice, they can upload later in their account settings
    9. Leave multiple values unchecked
    10. Click "save field settings"
  4. Integrate into registration process

    1. In Administer -> Content Management -> Content Types (where you should be after the previous step), click "edit" on the content type you created (Resume in this example)
    2. Click the option "Node Profile"
    3. Check/select the option "Integrate this node profile with user categories."
    4. Check/select the option "Show this node profile during user registration."
    5. Select the option "Display it as full node view"
    6. Check/select the option "Include an edit link to the display"
    7. Select "10" as the weight so is shown underneath username/email
    8. Click submit
  5. Grant access privileges

    1. In Administer -> User Management -> Access Control enable access for authenticated users to create resume (or whatever you called it) content and edit own resume content
    2. Click "save permissions"
  6. Try it out!

    1. Logout
    2. Create a new account!

Please do post and let us know if it worked for you OK!

http://www.open4.org/bio/steve-purkiss - view my online profile
http://www.open4.org/site_tour/quick_tour - free blogs and clubs with 100% AdSense revenue going to you!

thanks a lot! .... till day

hprashi - June 10, 2007 - 19:04

thanks a lot! ....

till day i had heard about how open communities work.... now i am witnessing it....

hats off!

Thanks

pmaster4 - June 26, 2007 - 01:05

Thanks i needed something like this will implement it

Create content menu?

ecarter - July 25, 2007 - 22:09

Hi, tried this out and it works great. I had one question, when I allow access to create the new node (called faculty_profile) the menu "Create content" appears. I'd like to hide this menu and only use the user screen to edit this. Is it possible to allow permission to create a new node without the "Create content" menu appearing?

Thanks for the great tutorial,
Eric
---
Nevermind, sorry I knew I'd figure it out once I posted. I realized that you just need to "disable" the menu item under Administer -> Menus. Then it hides the "Create Content" menu. This has helped me alot to allow faculty to upload their cv, thanks again.

Problem after following tutorial

vascopedro - October 21, 2007 - 07:28

Hi,

Thanks for the tutorial, it's exactly what I was looking for. The only problem is that when I upload a cv I get the following message

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM content_ WHERE vid = 0 LIMIT 0, 1' at line 1 query: SELECT FROM content_ WHERE vid = 0 LIMIT 0, 1 in /home/papsonli/public_html/includes/database.mysql.inc on line 172.

Any ideas what this could be?

Thanks,

Vasco

solved

vascopedro - October 21, 2007 - 08:21

I had messed up the permissions

Which permission was not right?

samirjusic - December 2, 2007 - 10:19

Hi vascopedro

I'm seeing the same error but can't seem to get rid of it.

The settings under node module (checked for authenticated user) are:
create resume content
edit own resume content
edit resume content

NOTE: I've named the new content type as per the solution above as "resume".

Unfortunately, this still doesn't work. Any suggestions since you said it was a permission problem?

Link to CV leads to user profile page and not file

vascopedro - October 21, 2007 - 09:01

Hi,

I guees the current bug is that when you look at the link to the profile, you actually get taken back to the user page. You can never download the CV.
What did I do wrong?

Thanks,

Vasco

Using custom profile and this method...

timech187 - February 6, 2008 - 19:54

I am able to use this method with success. However, I'd like to create a custom profile with not only my regular fields showing up but also the file attachment. Also, I can't get the resume to show up at the bottom of the page, even using the weight at 10.

any ideas?

Thanks!
Timech

Any other fields with wieght 10?

jmwhitco - March 17, 2008 - 20:34

timech187,

Were you able to resolve this?

If not, do you have any other fields in this CCK content type with weight 10?

Is there any way to improve

chrism2671 - June 10, 2008 - 16:03

Is there any way to improve the security of this? I don't want people other than people in a certain usergroup to be able to access the file, either by viewing it from the profile or typing a link to the file directly into the browser.

Installation of Filefield

timech187 - January 31, 2008 - 19:22

How do you install this module? I do it like my normal modules, but it doesn't show up to pick it in the Administrate > Modules. I'm kind of new...anyone that can give me a brief instruction on what to do? I notice that the unzipped folder has only one file with no extension.

Just not sure where to go from here....

Thanks!

Why don't you use hook_form_alter

subrata.das - March 11, 2008 - 09:52

It can be easily done through hook_form_alter

function hook_form_alter($form_id, &$form) {
if ($form_id == 'user_register') {
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['file'] = array(
'#type' => 'file',
'#title' => t('Title'),
'#size' => 40,
'#default_value' => '',
'#weight' => 6
);
}
}

And in hook_user

do following coding

case 'insert' :
$file = file_check_upload('file');
if ($file){
$file = file_save_upload($file,$filename);
db_query(");
...............
}

sorry: how do you do this in

luschink - April 10, 2008 - 17:40

sorry: how do you do this in drupal 6 ?

For drupal 6

subrata.das - August 6, 2008 - 08:43

You have to write same code using drupal 6 API. e.g. $form_state is used in hook_form_alter() function.

Hook_form_alter works but need help on hook_user

grib - August 30, 2008 - 14:41

Thanks for the code, I now have the upload box on the correct form, but I'm unsure what to do with the code for hook_user, I took a stab at it, but it just makes the site load with a blank page.

function profileplus_user() {
case 'insert' :
$file = file_check_upload('file');
if ($file){
$file = file_save_upload($file,$filename);
db_query(");
}

 
 

Drupal is a registered trademark of Dries Buytaert.