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?

Comments

Anonymous’s picture

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!

DesignWork’s picture

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

Anonymous’s picture

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!

DesignWork’s picture

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

Anonymous’s picture

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!

Anonymous’s picture

...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!

Anonymous’s picture

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!

DesignWork’s picture

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

hprashi’s picture

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

i couldnt follow :(

Anonymous’s picture

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!

hprashi’s picture

thanks a lot! ....

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

hats off!

pmaster4’s picture

Thanks i needed something like this will implement it

ecarter’s picture

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.

vascopedro’s picture

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

vascopedro’s picture

I had messed up the permissions

samireez’s picture

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?

vascopedro’s picture

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

timech187’s picture

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

jmwhitco’s picture

timech187,

Were you able to resolve this?

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

chrism2671’s picture

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.

timech187’s picture

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!

subrata.das’s picture

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(");
...............
}

luschink’s picture

sorry: how do you do this in drupal 6 ?

subrata.das’s picture

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

grib’s picture

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(");
}

nightlife2008’s picture

I suppose you could have a look at the original user picture file upload validator?

function user_validate_picture(&$form, &$form_state) {
  // If required, validate the uploaded picture.
  $validators = array(
    'file_validate_is_image' => array(),
    'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
    'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
  );
  if ($file = file_save_upload('picture_upload', $validators)) {
    // Remove the old picture.
    if (isset($form_state['values']['_account']->picture) && file_exists($form_state['values']['_account']->picture)) {
      file_delete($form_state['values']['_account']->picture);
    }

    // The image was saved using file_save_upload() and was added to the
    // files table as a temporary file. We'll make a copy and let the garbage
    // collector delete the original upload.
    $info = image_get_info($file->filepath);
    $destination = variable_get('user_picture_path', 'pictures') .'/picture-'. $form['#uid'] .'.'. $info['extension'];
    if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
      $form_state['values']['picture'] = $file->filepath;
    }
    else {
      form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array('%directory' => variable_get('user_picture_path', 'pictures'))));
    }
  }
}
nightlife2008’s picture

To do this, I suppose U should use the hook_form_alter() to modify a profile field "File" (of type textfield) into the proper file-upload field.

Once this is modified, the form gets rendered, and the textfield should be rendered as a file-upload box.

You should also add a new validator function to the user_register_form with $form['#validate'][] = 'MODULE_user_register_validate';

In this function, which receives both $form, and $form_state, as a normal form validate function, you can validate the uploaded file, save it in the DB if valid, and take only the relative file path.

Put this filepath into the $form['file']['#value'] and change it's type back to textfield.

Once everything is validated, the submit function should fire, containing hooks to the profile save api function, which should save the relative path into the DB...

I suppose you could then render this URL back into its download URL using file_create_url ?

sai01919’s picture

Thanks everyone... :)