We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • This is driving me nuts. I get this occasionally on MODx sites, but this time I can’t seem to fix it. This JS window pops up every time we try to upload a file into a TV field. We can choose the file, but as soon as we click upload, we get this error:
    Failed to upload file, internal error...

    I’ve checked all the file paths according to a few other similar posts, and I even tried variations, but I cannot get this thing to go away.

    I’ve tracked the error down to this file around line 170 manager/media/browser/mcpuk/connectors/php/Commands/FileUpload.php, in this block:
    //Upload file
    if (is_uploaded_file($_FILES['NewFile']['tmp_name'])) {
            if (move_uploaded_file($_FILES['NewFile']['tmp_name'],($this->real_cwd."/$filename.$ext"))) {
                    @chmod(($this->real_cwd."/$filename.$ext"),$this->fckphp_config['modx']['file_permissions']); //modified for MODx
                    $disp="0";
            } else {
                    $disp="202,'Failed to upload file, internal error... real_cwd:".$this->real_cwd." filename: $filename.$ext'"; //<-- This line
            }
    } else {
            if (rename($_FILES['NewFile']['tmp_name'],($this->real_cwd."/$filename.$ext"))) {
                    @chmod(($this->real_cwd."/$filename.$ext"),$this->fckphp_config['modx']['file_permissions']); //modified for MODx
                    $disp="0";
            } else {
                    $disp="202,'Failed to upload file, internal error...'";
            }
    }


    I modified the popup window to verify that the file and path information was wrong. Specifically it’s picking up
    /home/myuser/public_html/images/

    as the "real_cwd", so the file (e.g. named xyz.jpg) is trying to upload to the images folder at the root of the site (which doesn’t exist).

    I know this is probably the wrong approach to tear this apart at this level, but man, I cannot figure out how the @#%! this is screwing up and I’m a bit miffed that there isn’t any logging or other visible checks on this thing to ensure that it’s actually configured correctly before flipping the user the dreaded pop-up error.

    Anyone out there got ideas for this?
    • Looks like I’m going this alone. For the record, there ARE some log files for this that I spotted because of SVN and rsync:


      • manager/media/browser/mcpuk/connectors/php/error_log
      • manager/media/browser/mcpuk/connectors/php/Commands/error_log

      • Upgrading to MODx 1.0.3 did not fix the problem. I found a workaround... since I modified the JS popup, I could see exactly where this was attempting to upload files, so I just created the directory there and granted it permissions. I just don’t want it pointing there.
          • 7914
          • 137 Posts
          Hi Everett, I am also running into the same problem. Document root is correct, I am using Rackspace Cloud as a host. I have contacted them to empty the temp upload directory as I have read in other posts that (that) has been a problem.

          I am curious to know how/what you modified on your js file to display where MODx (FCK) is trying to upload to.

          I have upgraded to MODx 1.0.3, file permissions are set to 777. Locally my site works perfect. Once I upload to my dev server... no luck. I get the infamous: Error, "Failed to upload file, internal error..."

          Thank you for your time.
          • I have that problem after migrating from development to production when on different machines, make sure you check the Tools > Configuration > File Manager > File Manager Path (first input field) is pointed to the correct path of your site and includes the trailing slash at the end.

              Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
              Visit CharlesMx.com for latest news and status updates.
              • 7914
              • 137 Posts
              Yeah I uploaded a dummy file with phpinfo() to make sure I had the correct document root. Since I am on a cloud site it’s kind of long.. has 3 directories before I get to my site. /dir/dir/dir/[mysite.com]/web/content/

              I also read a post in the forums to make sure the user in the security tab has the same path(s). I have contacted rackspace to purge my temp upload directory, just waiting to hear back. I’m not holding my breath though. smiley
              • I put in a javascript alert somewhere... can’t remember now. This has been a while, so I can’t even remember what site I was having this problem on.
                • you also might want to double check your folder permissions and make sure it has read/write access from web (755) if you want to fully test
                    Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
                    Visit CharlesMx.com for latest news and status updates.
                    • 22295
                    • 153 Posts
                    Quote from: charless at Apr 22, 2010, 06:35 AM

                    you also might want to double check your folder permissions and make sure it has read/write access from web (755) if you want to fully test

                    Actually, you need 777
                    And if there was a directory structure already there, for example, if you transfered you development (on windows) to the production (on linux) then - not only on /assets/images/ , but recurse on all subdirectories inside it (folders only, not files).
                    This solves the issue.