<![CDATA[ Login UpdateProfile question re: saving data to extended field from file input form field - My Forums]]> https://forums.modx.com/thread/?thread=98622 <![CDATA[Login UpdateProfile question re: saving data to extended field from file input form field]]> https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533291
I am allowing my members of a website to update a file they upload to dropbox and storing the filename of the file they upload to their MODx user profile using "UpdateProfile". The file uploading all works fine - but what is not happening is the storing of the new filename of the file they have uploaded being stored to the modUser extended field.

My upload to dropbox code works on a posthook currently.

How can I add in my pre/post hook to store the value of the file input "fileName" to the extended field "thisDoc".

Help!


Cheers

dubbs.]]>
dubbs Oct 16, 2015, 12:00 PM https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533291
<![CDATA[Re: Login UpdateProfile question re: saving data to extended field from file input form field]]> https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533455 Quote from: BobRay at Oct 21, 2015, 04:23 AM
Maybe you don't really have the $profile object and/or the $upload_name. The rest of the code looks fine.

If it's the current user, you should be able to do this for the profile:

$profile = $modx->user->getOne('Profile');


Thanks Bob - seems that was indeed the missing element!!!! Many thanks wink]]>
dubbs Oct 21, 2015, 06:42 AM https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533455
<![CDATA[Re: Login UpdateProfile question re: saving data to extended field from file input form field (Best Answer)]]> https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533435
If it's the current user, you should be able to do this for the profile:

$profile = $modx->user->getOne('Profile');

]]>
BobRay Oct 20, 2015, 11:23 PM https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533435
<![CDATA[Re: Login UpdateProfile question re: saving data to extended field from file input form field]]> https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533417
$extended = $profile->get('extended');
$extended['thisDoc'] = $upload_name;
$profile->set('extended', $extended);
$profile->save();


So 'thisDoc' is the extendedField name and $upload_name is the PHP var which contains the filename I want to store in 'thisDoc' extended field... I am calling this on a PostHook...

Why is it not working???

I get a server error when I use this approach- logic would say it should work... something I am not understanding somewhere... huh]]>
dubbs Oct 20, 2015, 10:37 AM https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533417
<![CDATA[Re: Login UpdateProfile question re: saving data to extended field from file input form field]]> https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533361
Thanks guys wink]]>
dubbs Oct 19, 2015, 12:42 PM https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533361
<![CDATA[Re: Login UpdateProfile question re: saving data to extended field from file input form field]]> https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533341
Currently - on profile update - the new file is uploaded nicely, but the "thisDoc" modUser field becomes an array with subsets of file info rather than storing just the filename... Any ideas how to make it just save the filename as a string?

e.g. it currently saves as below (e.g. it looks like this when you view the extended field in the USER view in the MODx manager):

thisDoc
>_ name - example.jpg
>_ type - image/jpeg
>_ tmp_name - blah/blah.jpg
>_ error - 0
>_ size - 999

This means - that when you try and call "thisDoc" field back in to a page it displays as blank - rather than showing the filename which is what I want - e.g. should display "example.jpg" i.e. I want to display the first attribute (name) of the container when I call to display [[+thisDoc]] field.

Any ideas?]]>
dubbs Oct 19, 2015, 04:37 AM https://forums.modx.com/thread/98622/login-updateprofile-question-re-saving-data-to-extended-field-from-file-input-form-field#dis-post-533341