Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Image upload field?

  1. #1
    Thyssen is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    38

    Default Image upload field?

    I want to have a field that allows an end user to select an image and it will display it.
    I followed this entire thread https://www.sugarcrm.com/forums/showthread.php?t=26723 and did like the author said but all I get is a BROWSE button, I browse to the image but it does not upload it, so I cant see it.
    The only way this works is if I manually take the image and copy it to the images folder inside of \include\SugarFields\Photo\phpThumb\images

    But I dont want users to manually place those images there, i want it to upload it automatically.
    Anyone ever get this working or have another version I can use?

    Please please help Thanks

  2. #2
    Thyssen is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    38

    Default Re: Image upload field?

    I cannot believe there is not one person that has used sugarcrm that does not have an answer for this.
    No one has ever wanted or uses an Image Upload field, where you click a Browse button find an image and upload it??? It then displays the image in the field? Please any experts in this forum at all ?

  3. #3
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

  4. #4
    Thyssen is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    38

    Default Re: Image upload field?

    Quote Originally Posted by eggsurplus View Post
    You must be like the others and did not read my post. i USED the first link that you posted, if you read my first thread that I started, but the issue I am having is when I browse to a photo I can select it but it never uploads the photo hence the image is never there...

    So I need help and that is why I posted this!

  5. #5
    Thyssen is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    38

    Default Re: Image upload field?

    Quote Originally Posted by eggsurplus View Post
    Amazingly the first two links are what I used, see my original post where I EVEN LINK TO IT.

    The third one is an inventory module, which I DONT WANT.

    The last one is a post of someone who does not know how to do it to.

    Apparently that was no help. Anyone else with some REAL good suggestions rather then what is already there. All I am having trouble with is when I browse to the image and select it it puts the path in the text box but never uploads the image....

  6. #6
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Image upload field?

    I can see why no one wants to help you.

    The inventory module is an example from which you may get something out of. I'm not pushing the inventory module for your needs, obviously. You would need to work to get the resolution still.

    If what you need is an image uploader then I recommend the ajaxfilemanager. We use this to upload images along with inserting them into our emails that we send out from Sugar. You could merge this with the solution you have to get what you're looking for. You have a working image tool, you just need a way to upload them to the server now in one spot. I'd give you more information but I don't want to accidentally give you information that you know already as that really offends you.

  7. #7
    Thyssen is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    38

    Default Re: Image upload field?

    Quote Originally Posted by eggsurplus View Post
    I can see why no one wants to help you.

    The inventory module is an example from which you may get something out of. I'm not pushing the inventory module for your needs, obviously. You would need to work to get the resolution still.

    If what you need is an image uploader then I recommend the ajaxfilemanager. We use this to upload images along with inserting them into our emails that we send out from Sugar. You could merge this with the solution you have to get what you're looking for. You have a working image tool, you just need a way to upload them to the server now in one spot. I'd give you more information but I don't want to accidentally give you information that you know already as that really offends you.
    My point was you assumed I did not search in the forums, when in my initial post I posted a link that is exactly referencing the link you posted (first 2 links). So you suggested I did not research, when you yourself fell guilty of not even reading the post.

    If you want ot be helpful then read the post, don't assume people don't research. I'm a .net programmer with sql server 2k5 experience, very new to sugarcrm. So I definately need the help as I dont know PHP very well. i was able to write up some logic hooks by using existing code...

    However, my issue is that the POSTED SOLUTION states that it is supposed to upload the image and then display it, mine does not do that. I have done everything the author has stated. Unfortunately that thread seems to be locked as you cannot reply to it. I'm just looking for help not a smart alec that is all. I'm here to get work done and help others. in fact I posted an autonumber generator hook the other day that helps the SQL Server folks rather then MySQL. I posted it freely because this IS OPEN SOURCE.

    Obviously you don't believe in that...

  8. #8
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Image upload field?

    You want to turn this into a flame war? That's all this whole thing has been for you.

    I posted it freely because this IS OPEN SOURCE.

    Obviously you don't believe in that...
    Good for you. But don't think for a second that you are the only one that does so. If you are going to call me out for assuming that you didn't search I'm going to call you out for assuming that I don't believe in that. Most of my posts are in the name of OPEN SOURCE. I've given hundreds of solutions to others on here to better the flow of information. I have given hundreds of hours worth or work if not thousands for free to individuals like yourself in not just these stupid posts but with my projects on SugarForge. Before you go blowing hot air and picking a flame war with someone go do a little research on the individual. Everything I do here is for the people of this community.

    I'm just looking for help not a smart alec that is all. I'm here to get work done and help others.
    We're in the same freaking boat. I understand how it can be frustrating that you can't find an answer for your issues. It's happened to me a few dozen times. Then I had to go back and post the solution I eventually found. I'm sure you're the same way.

    Good luck and thanks for pointing out one mistake I made in not reading your post fully. Yes, I screwed up. Get over it. It happens once in awhile when trying to help others on my own time.

    Now to accomplish what you want google ajaxfilemanager. This may be what you need.
    Last edited by eggsurplus; 2008-12-10 at 07:19 PM. Reason: No need for some of the text.

  9. #9
    Thyssen is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    38

    Default Re: Image upload field?

    egg,

    Sorry im not here for a flame war. In honesty im here to receive and give help, sorry I offended you if I have. You are right my tone was out of whack..I guess I had a bad day yesterday..my appologies.

    Egg,

    My issue is I dont know too much PHP so even if I google that I dont know how to really embed something like that into sugar. What I did do was follow those steps in the first post link that I posted. I can see everything and when I click the browse button to upload an image it just pastes the path in the text box it never uploads the image. Do you think I could be missing something critical???

  10. #10
    jhermiz is offline Senior Member
    Join Date
    Dec 2008
    Posts
    22

    Default Re: Image upload field?

    Hi Egg,

    Its thyssen again I forgot my password for the forums / had trouble with the account when logging in (its flacky at times, besides I wanted to use this user name). To get a feel for my issues I decided to take some screen shots of my issues. Outside of sugar Im calling this iframe.php file so that you can see what it all looks like:


    http://img168.imageshack.us/my.php?i...2310799no9.gif


    So then I simply click the browse button here to select my image:


    http://img266.imageshack.us/my.php?i...1504220bu3.gif

    I select the image and all it does is paste the file into the text field, it does not do anything else. It is supposed to upload the picture file to a directory and display a loading indicator.


    http://img168.imageshack.us/my.php?i...3198166id5.gif

    So as you see the screen shots everything looks right but it doesn't function right. Here is the code for iframe.php:

    Code:
    <?php 
    
    $sugarFieldName = $_GET['sugarFieldphp'];
    
    ?>
    
    <script type="text/javascript" language="javascript">
    
    /* standard small functions */
    function $m(quem){
     return document.getElementById(quem)
    }
    function remove(quem){
     quem.parentNode.removeChild(quem);
    }
    function addEvent(obj, evType, fn){
     // elcio.com.br/crossbrowser
        if (obj.addEventListener)
            obj.addEventListener(evType, fn, true)
        if (obj.attachEvent)
            obj.attachEvent("on"+evType, fn)
    }
    function removeEvent( obj, type, fn ) {
      if ( obj.detachEvent ) {
        obj.detachEvent( 'on'+type, fn );
      } else {
        obj.removeEventListener( type, fn, false ); }
    } 
    /* THE UPLOAD FUNCTION */
    
    
    var sugarField = window.parent.<? echo $sugarFieldName; ?>_sugarField();
    
    function micoxUpload(form,url_action,id_element,html_show_loading,html_error_http,thisFileId){
    var fileAndPath = thisFileId.value;
    var lastPathDelimiter = fileAndPath.lastIndexOf('\\');
    var fileNameOnly = fileAndPath.substring(lastPathDelimiter+1);
    
    window.parent.document.getElementById(sugarField).value = fileNameOnly;
    /******
    * micoxUpload - Submit a form to hidden iframe. Can be used to upload
    * Use but dont remove my name. Creative Commons.
    * Versão: 1.0 - 03/03/2007 - Tested no FF2.0 IE6.0 e OP9.1
    * Author: Micox - Náiron JCG - elmicoxcodes.blogspot.com - micoxjcg@yahoo.com.br
    * Parametros:
    * form - the form to submit or the ID
    * url_action - url to submit the form. like action parameter of forms.
    * id_element - element that will receive return of upload.
    * html_show_loading - Text (or image) that will be show while loading
    * html_error_http - Text (or image) that will be show if HTTP error.
    *******/
    
     //testing if 'form' is a html object or a id string
    
    
     //creating the iframe
     var iframe = document.createElement("iframe");
     iframe.setAttribute("id","micox-temp");
     iframe.setAttribute("name","micox-temp");
     iframe.setAttribute("width","0");
     iframe.setAttribute("height","0");
     iframe.setAttribute("border","0");
     iframe.setAttribute("style","width: 0; height: 0; border: none;");
     
     //add to document
     form.parentNode.appendChild(iframe);
     window.frames['micox-temp'].name="micox-temp"; //ie sucks
     
     //add event
     var carregou = function() { 
       removeEvent( $m('micox-temp'),"load", carregou);
       var cross = "javascript: ";
       cross += "window.parent.$m('" + id_element + "').innerHTML = document.body.innerHTML; void(0); ";
       
       $m(id_element).innerHTML = html_error_http;
       $m('micox-temp').src = cross;
       
       //del the iframe
       
       setTimeout(function(){ remove($m('micox-temp'))}, 250);
      }
     addEvent( $m('micox-temp'),"load", carregou)
     
     //properties of form
     form.setAttribute("target","micox-temp");
     form.setAttribute("action",url_action);
     form.setAttribute("method","post");
     form.setAttribute("enctype","multipart/form-data");
     form.setAttribute("encoding","multipart/form-data");
     //submit
     form.submit();
     
     //while loading
     if(html_show_loading.length > 0){
      $m(id_element).innerHTML = '<img src="' + html_show_loading + '">';
     }
     
    thisFileId.style.display = 'none';
     
    }
    
    </script>
    
    <form>
    <input 
    type="file" 
    id="file" 
    value=""  
    name="file" 
    onChange="micoxUpload(this.form,'upload.php','upload_2','indicator.gif','Error in upload',this);" 
    />
    </form>
    <div id="upload_2">&nbsp;</div>
    And it calls upload.php here is the code for 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">';
    	}
      }
     }
    ?>
    Do you see any issue with this at all? Any php people on here who might be able to see an issue?
    We are running on IIS6, Windows 2k3, and sugar 5.0.1b.

    Thanks,
    Jon

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Image Upload Not Working After Install
    By gorpus in forum Installation and Upgrade Help
    Replies: 3
    Last Post: 2009-02-18, 11:13 PM
  2. Upload image XML error
    By Breier in forum Help
    Replies: 0
    Last Post: 2007-11-07, 01:14 PM
  3. Replies: 1
    Last Post: 2007-01-10, 10:01 AM

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
  •