So, I know that this is for a year, but I had the same problem, and I figured out how to load attachments. Files in the message are stored in the environment variable $ _ FILES . The information for each file will look something like this:
Array ( [attachment-1] => Array ( [name] => ATextFile.txt [type] => text/plain [tmp_name] => /tmp/php8zhmlU [error] => 0 [size] => 70144 ) )
The file path is stored in tmp_name , so in this case /tmp/php8zhmlU is the full path to the file. move_uploaded_file will overwrite any existing files! To download all attachments from POST , I wrote a function:
function download_attachments($pathToDownloadDirectory) { foreach($_FILES as $file) { if($file['error'] == "0") { if(!(move_uploaded_file($file['tmp_name'], $pathToDownloadDirectory . $file['name']))) { return 0; } } else { return 0; } } return 1; } download_attachments("/Full/Path/To/Some/Dir/");
The documentation for this top can be found here.
source share