CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • How to upload an image to a contact's data
Pages: [1]

Author Topic: How to upload an image to a contact's data  (Read 600 times)

VitorFF

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 1
  • CiviCRM version: 4.4.11
  • CMS version: Drupal 7.27
  • MySQL version: 5.5
  • PHP version: 5.4
How to upload an image to a contact's data
October 20, 2014, 07:48:17 am
Hello everyone,

What is the best way to upload a picture to a contact's data?
I have an extension page that allows users to modify their contact image. How do I upload the file on the extension page and save it's URL on the contact 'image_URL' field?


I've look at previous topics such as http://forum.civicrm.org/index.php?topic=27122.0 but I don't see anything that would help me.

Thank you!
VitorFF
Why don't you take a look at this? (You will not regret it!)

Capitalisation Corrector : https://civicrm.org/extensions/capitalisation-corrector

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: How to upload an image to a contact's data
October 20, 2014, 09:12:43 am
See http://forum.civicrm.org/index.php?topic=7921.5 for some ideas.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

VitorFF

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 1
  • CiviCRM version: 4.4.11
  • CMS version: Drupal 7.27
  • MySQL version: 5.5
  • PHP version: 5.4
Re: How to upload an image to a contact's data
October 21, 2014, 08:02:16 am
Hello all!

We've decided to add a small form to upload the picture:

Code: [Select]
<form action="Questions.php" method="POST" enctype='multipart/form-data'>
            <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
            <input type="file" name="logo">
              <input class='button' type="submit" value="Upload File">
          </form>

The problem now is that the $_FILES global comes out empty. The file names appears on the $_POST variable, but that's it.

Thank you!

VitorFF
Why don't you take a look at this? (You will not regret it!)

Capitalisation Corrector : https://civicrm.org/extensions/capitalisation-corrector

VitorFF

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 1
  • CiviCRM version: 4.4.11
  • CMS version: Drupal 7.27
  • MySQL version: 5.5
  • PHP version: 5.4
Re: How to upload an image to a contact's data
October 22, 2014, 01:47:49 am
Hi all!

I solved the previous issue by building the form in the buildQuickForm() hook. All I have to do now is save the file correctly!

Does any one have any idea on how to do it?

Thank you!

VitorFF
« Last Edit: October 22, 2014, 03:29:18 am by VitorFF »
Why don't you take a look at this? (You will not regret it!)

Capitalisation Corrector : https://civicrm.org/extensions/capitalisation-corrector

VitorFF

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 1
  • CiviCRM version: 4.4.11
  • CMS version: Drupal 7.27
  • MySQL version: 5.5
  • PHP version: 5.4
Re: How to upload an image to a contact's data
October 27, 2014, 03:35:47 am
Hello!

Thanks Hershel for your post, I was able to save the image using your code as a reference!

Thanks!

VitorFF
Why don't you take a look at this? (You will not regret it!)

Capitalisation Corrector : https://civicrm.org/extensions/capitalisation-corrector

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: How to upload an image to a contact's data
October 27, 2014, 09:35:36 am
You could save yourself a lot of custom code & future maintanance by using Webform-CiviCRM-Integration for this
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • How to upload an image to a contact's data

This forum was archived on 2017-11-26.