Page 1 of 4 1234 LastLast
Results 1 to 10 of 37

Thread: 4.5.d attatchments corrupted!

  1. #1
    HenrikE is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    94

    Default 4.5.d attatchments corrupted!

    Hi!
    This is starting to get ridiculous. After the upgrade to 4.5.0d the email attacments gets corrupted. Don't know where to start looking and I need all the help I can get. To start with, where does the attachments get stored on the server?
    Here's my downloaf.php. Maby there's something wrong there?
    PHP Code:
    die("Not a Valid Entry Point");
    } else {
        
    // cn: bug 8753: current_user's preferred export charset not being honored
        
    $current_user->retrieve($_SESSION['authenticated_user_id']);
        
    $current_language $_SESSION['authenticated_user_language'];
        
    $app_strings return_application_language($current_language);
        
    $local_location $sugar_config['upload_dir']."/".$_REQUEST['id'];
        
        if (!
    file_exists$local_location ))
        {
            die(
    $app_strings['ERR_INVALID_FILE_REFERENCE']);
        }
        else if (
    strpos($local_location"../") || strpos($local_location"..\\") ) {
            die(
    $app_strings['ERR_INVALID_FILE_REFERENCE']);
        }
        else
        {
            global 
    $locale;
            
            if (
    strtolower($_REQUEST['type']) == 'documents'){
                
    $query "SELECT filename FROM document_revisions WHERE id = '" $_REQUEST['id'] ."'";
            }
            else if (
    strtolower($_REQUEST['type']) == 'notes'){
                
    $query "SELECT filename FROM notes WHERE id = '" $_REQUEST['id'] ."'";
            }
            
            
    $rs $db->query($query);
            
    $row $db->fetchByAssoc($rs);
            
            if (empty(
    $row)){
                die(
    $app_strings['ERR_INVALID_FILE_REFERENCE']);
            }
            
            
    $name $locale->translateCharset($row['filename'], 'UTF-8'$locale->getExportCharset());
            
    $download_location=$sugar_config['upload_dir']."/".$_REQUEST['id'];
            
            
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            
    header("Content-type: application/force-download");
            
    header("Content-Length: " filesize($local_location));
            
    header("Content-disposition: attachment; filename=\"".$name."\";");
            
    header("Pragma: no-cache");
            
    header("Expires: 0");
            
    set_time_limit(0);
            
            
    ob_start();
            if (
    filesize($local_location) < 2097152) {
                
    readfile($download_location);
            }
            else {
                
    readfile_chunked($download_location);
            }
            @
    ob_flush();
        }


  2. #2
    george_bbch is offline Sugar Community Member
    Join Date
    Jan 2006
    Location
    Switzerland
    Posts
    349

    Default Re: 4.5.d attatchments corrupted!

    Hi!

    What kind of attachment have you tried and which e-mail client have you used to send it?
    If you like, forward an example to me, I can try it here, too.

    Cheers,
    George

  3. #3
    sugarchris's Avatar
    sugarchris is offline Sugar Community Member
    Join Date
    Sep 2005
    Location
    San Francisco, CA
    Posts
    861

    Default Re: 4.5.d attatchments corrupted!

    Attachments are stored in [sugar]/cache/upload.

    The naming scheme is simple - find the GUID (id) of the note/attachment, and that is the name of the file. No extension, no filename.

    Based on the stored filename, we stream the bits to your browser.

    Our testing with .pdf, .doc, .xls, .txt, .zip, and others were all 100% successful.

  4. #4
    HenrikE is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    94

    Default Re: 4.5.d attatchments corrupted!

    Thnx for trying to help me!
    I've tried both xls, docs, and jpg's. I use a jpg as an example this time:
    * Sending the attachment is working (I've tested open it in outlook)
    * After recieving the email I can find the attachment in the cache/upload folder with the name "eeb28021-7ba9-c9f5-c96d-452d4ff25b89" without the extension .jpg (Is this right, should the filename be without extension?)
    If I try to download the file from sugar the file gets corrupted but if I download the file by ftp and add .jpg I can open the file without any problem. So the error can be in two places
    1. When saving the file in upload folder sugar dosn't add the extension
    2. The file gets corrupted when downloading.
    Any ideas?

  5. #5
    sugarchris's Avatar
    sugarchris is offline Sugar Community Member
    Join Date
    Sep 2005
    Location
    San Francisco, CA
    Posts
    861

    Default Re: 4.5.d attatchments corrupted!

    The main reason an attachment is getting corrupted on download is an error is occuring during the process, outputting some text inline. This interferes with the headers and causes premature termination of data streaming.

    Check your PHP error log file, the apache logfile and the sugarcrm.log file. See if any are showing errors relevant to the download.

    If so, post them here, we can all try to figure out what is going wrong.

  6. #6
    HenrikE is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    94

    Default Re: 4.5.d attatchments corrupted!

    Nothing in the sugarcrm.log
    two quick questions.
    1. Should the files in cache/uploads have file extensions? My files just look like "31a6faf8-84d6-2456-06be-45080c63fe73"
    2. Is there any change in the download.php between 4.5 and 4.5d? The file download worked in 4.5

  7. #7
    rsm
    rsm is offline Member
    Join Date
    Feb 2006
    Posts
    8

    Default Re: 4.5.d attatchments corrupted!

    Hi!

    I have the exact same problem with version 4.5.c
    Files are ok on the server.
    When I rename them (adding the extension) I can open the documents but when I download the file through sugar and save it to my local machine (or open it directly) the file is corrupted.

    Same happens to rar, zip, pdf and doc files!

    I hope anyone can help!

  8. #8
    rsm
    rsm is offline Member
    Join Date
    Feb 2006
    Posts
    8

    Default Re: 4.5.d attatchments corrupted!

    btw I haven't found any relevant error in the log files.

    I run: Apache/2.2.3 (Win32) mod_ssl/2.2.3 OpenSSL/0.9.8b PHP/5.1.5 mod_perl/2.0.3-dev Perl/v5.8.8 on Win2k3 Server

  9. #9
    rsm
    rsm is offline Member
    Join Date
    Feb 2006
    Posts
    8

    Default Re: 4.5.d attatchments corrupted!

    After downloading a zip file I was able to repair the corrupted zip file using winrar.
    Perhaps this is another clue...

  10. #10
    rsm
    rsm is offline Member
    Join Date
    Feb 2006
    Posts
    8

    Default Re: 4.5.d attatchments corrupted!

    When running cron.php I get an error.
    This is the only error that my sugar installation gives, but it is not logged in the sugarlog.
    I did not get this error a while back and I don't know if it is related.

    C:\www\webroot\sugar>php.exe -f cron.php
    PHP Warning: ini_set(): Cannot change zlib.output_compression - headers
    already sent in C:\www\webroot\sugar\include\utils.php on line 2755
    Last edited by rsm; 2006-10-12 at 01:05 PM.

Page 1 of 4 1234 LastLast

Thread Information

Users Browsing this Thread

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

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
  •