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?