Results 1 to 9 of 9

Thread: How to Create a custom Datatype to uplad an Image?

  1. #1
    gokulakannan is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    37

    Default How to Create a custom Datatype to uplad an Image?

    Hai friends
    I created a custom module in SugarCE6.4. In that i want to add a field in which user can able to upload an image file. need your help to do this.

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: How to Create a custom Datatype to uplad an Image?

    You should create a module based on File template.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    rafael.q.g@hotmail.com's Avatar
    rafael.q.g@hotmail.com is offline Sugar Community Member
    Join Date
    Jun 2011
    Location
    Florianópolis - Brazil
    Posts
    782

    Default Re: How to Create a custom Datatype to uplad an Image?

    Whether do you want to create a more reusable field to file upload you could develop your own fileupload field type. It will requires more development skills.

    The new sugar fields types could be created under /include/SugarFields/Fields.
    Rafael Queiroz Gonçalves
    Advanced OMG UML Certified Professional
    Sun Certified Enterprise Architect for the Java Platform
    Sun Certified Programmer for the Java 2 Platform
    IBM Certified Advanced Application Developer - Lotus Notes and Domino
    IBM Certified Application Developer - IBM WebSphere Portlet Factory
    Computer Science Mastering / UFSC - PPGCC

  4. #4
    mrbarletta is offline Junior Member
    Join Date
    Jun 2009
    Posts
    6

    Lightbulb Re: How to Create a custom Datatype to uplad an Image?

    check this out it may help

    http://www.sugarcrm.com/forums/f3/up...ord-how-77680/

    pura vida!

  5. #5
    gokulakannan is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    37

    Default Re: How to Create a custom Datatype to uplad an Image?

    Quote Originally Posted by mrbarletta View Post
    check this out it may help

    http://www.sugarcrm.com/forums/f3/up...ord-how-77680/

    pura vida!
    Thanks for your reply...
    But my doubt is how to create image datatype? You told that create a field of type image, but i cant able to create it. I am using SugarCE6.4.0RC2, there is no datatype "image" in the dropdown list.

    Need more guidance to do the need

  6. #6
    johnsellinge is offline Junior Member
    Join Date
    Feb 2012
    Posts
    1

  7. #7
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    402

    Default Re: How to Create a custom Datatype to uplad an Image?

    Hi gokulakannan I did it in detailview, and it works. I did in this way:

    In custom/modules/yourmodule/detailviewdefs.php

    PHP Code:
    'panels' => array(
     
    'lbl_yourlabel'=>array(
    array(
                        array(
                        
    'customCode' => '
                        
                        <form action="upload.php" method="post" enctype="multipart/form-data" name="form" target="_blank"> 
                        <label for="file">File</label>
                        <input name="file" type="file" id="archivo" /> //this is the type file which you need
                        <input name="button" type="submit" id="button" value="Send" />                
                        </form>'
    ,),    
    ),        
    ), 
    And in the root of your sugarcrm, you create a file named upload.php with something like:

    PHP Code:
    <?php

    $uploaddir 
    'docs/'// for example, your image will be save in this directory
     
     //////////////////////////////////////////

     
    $uploadfile $uploaddir basename($_FILES['file']['name']);
     
    $error $_FILES['file']['error'];
     
    $uploaded false;
     if(isset(
    $_POST['button']) && $error==UPLOAD_ERR_OK){ 
       
    $uploaded copy($_FILES['file']['tmp_name'], $uploadfile); 
      } 
       if(
    $uploaded) { 
        echo 
    "File uploaded"
       } else {
        echo 
    "Error: ".$error;
      }
    ?>

  8. #8
    Ramblin is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    98

    Default Re: How to Create a custom Datatype to uplad an Image?

    If you have the Pro or Ent versions of SugarCRM, they now have an image field type. Not so for the CE version.

    For the CE version, try the module from eggsurplus (make sure you get v1.3) at eggsurplus solutions | Your Personal Developer - $49.95

    It is simple and it works

  9. #9
    kingofdrak is offline Junior Member
    Join Date
    Mar 2012
    Posts
    1

    Default Re: How to Create a custom Datatype to uplad an Image?

    Quote Originally Posted by garciasanchezdaniel View Post
    Hi gokulakannan I did it in detailview, and it works. I did in this way:

    In custom/modules/yourmodule/detailviewdefs.php

    PHP Code:
    'panels' => array(
     
    'lbl_yourlabel'=>array(
    array(
                        array(
                        
    'customCode' => '
                        
                        <form action="upload.php" method="post" enctype="multipart/form-data" name="form" target="_blank"> 
                        <label for="file">File</label>
                        <input name="file" type="file" id="archivo" /> //this is the type file which you need
                        <input name="button" type="submit" id="button" value="Send" />                
                        </form>'
    ,),    
    ),        
    ), 
    And in the root of your sugarcrm, you create a file named upload.php with something like:

    PHP Code:
    <?php

    $uploaddir 
    'docs/'// for example, your image will be save in this directory
     
     //////////////////////////////////////////

     
    $uploadfile $uploaddir basename($_FILES['file']['name']);
     
    $error $_FILES['file']['error'];
     
    $uploaded false;
     if(isset(
    $_POST['button']) && $error==UPLOAD_ERR_OK){ 
       
    $uploaded copy($_FILES['file']['tmp_name'], $uploadfile); 
      } 
       if(
    $uploaded) { 
        echo 
    "File uploaded"
       } else {
        echo 
    "Error: ".$error;
      }
    ?>
    OK man. Your code helped me to resolve my problem. Thanks for share

    --------------------------------
    Game Avatar HD | game avatar moi nhat

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. creating custom time datatype?
    By kazuoF in forum Help
    Replies: 0
    Last Post: 2011-01-05, 07:41 AM
  2. Replies: 2
    Last Post: 2010-01-12, 04:25 PM
  3. Empty Datatype-List / Custom Field
    By HeiligerBimBam in forum Help
    Replies: 2
    Last Post: 2009-07-26, 05:18 PM
  4. Custom field with 'date' datatype not saved
    By Christoph in forum Help
    Replies: 0
    Last Post: 2005-07-12, 02:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •