Move_uploaded_file - nor working on formit hook

Hello, I’m having problems running this line inside a hook in formit.

if(move_uploaded_file($_FILES[$sf]['tmp_name'], $myTarget)) {...

Pats to folders and file names are all right:

$myTarget = $target_path . $storeName . ‘_’ . $filename;

I can see the pats in the error log and everything is ok:

$modx->log(modX::LOG_LEVEL_ERROR, $_FILES[$sf]['tmp_name']);
$modx->log(modX::LOG_LEVEL_ERROR, $myTarget);

The file is uploaded successful into assets/components/formit/tmp/

but it’s not moving it.

the /tmp/ folder has permissions 0755 but I tried 1777 but still not working.

any ideas? thanks!

1 Like

found the answer here:

Just replace

if(move_uploaded_file($_FILES[$sf]['tmp_name'], $myTarget)) {...


if(rename($_FILES[$sf]['tmp_name'], $myTarget)) {...


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.