Results 1 to 3 of 3

Thread: New image field type

  1. #1
    nat8100 is offline Senior Member
    Join Date
    May 2009
    Posts
    27

    Default New image field type

    Hi, I was wondering if anyone could help me with this.

    I wanted to create a new image field type. This is to actually display an image within the form. The use is for a recruitment module - I want to be able to view a photo of each candidate along with the rest of the details.

    I found this post:

    http://www.sugarcrm.com/forums/showt...t=26723&page=2

    which was helpful.

    I used the code suggested and uploaded the new field type folder 'photo' into include/sugarfields/fields/

    I then changed the field type in editviewdefs.php and detailviewdefs.php

    I also had to remove a couple of lines from my htaccess file so it displayed correctly.

    The problem I have it the image file doesn't actually upload. I can browse for it and select, it stores the filename value, but doesn't upload.

    If I manually FTP the image afterwards it displayed fine.

    I thought maybe it might be a permissions problem, but I have now set the folders to 777

    This is the code from upload.php

    Code:
    <?php
    $target_path = 'phpThumb/images/' . basename( $_FILES["file"]["name"]);
    
    if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") && ($_FILES["file"]["size"] < 20000)){
      if ($_FILES["file"]["error"] > 0){
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
      }else{
    	if (file_exists("phpThumb/images/" . $_FILES["file"]["name"])){
          echo '<br />' . $_FILES["file"]["name"] . ' already exists.';
        }else if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)){
    		chmod($target_path, 0644);
    		echo '<img src="phpThumb/phpThumb.php?src=images/' . $_FILES["file"]["name"] . '&h=80&w=80">';
    	}
      }
     }
    ?>
    Any suggestions would be greatly appreciated. Thank you

  2. #2
    nat8100 is offline Senior Member
    Join Date
    May 2009
    Posts
    27

    Default Re: New image field type

    Anyone?

    Or has anyone created image field type another way?

  3. #3
    lougaou's Avatar
    lougaou is offline Sugar Community Member
    Join Date
    Mar 2007
    Location
    Lyon - France
    Posts
    236

    Default Re: New image field type

    --------------------
    Xavier Rigal

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Image upload field?
    By Thyssen in forum General Discussion
    Replies: 23
    Last Post: 2009-12-07, 12:57 PM
  2. Image Uploader Field?
    By Thyssen in forum Developer Help
    Replies: 0
    Last Post: 2008-12-10, 01:45 PM
  3. Replies: 0
    Last Post: 2008-07-02, 10:11 PM
  4. Replies: 1
    Last Post: 2006-04-19, 01:44 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
  •