Wednesday, March 20, 2013

Re: Retrieve attachment from a Post - mailgun

Show the result of debug ($this->request->data);

That will either answer the question for you or show the data isn't there to be accessed.

AD

On Tuesday, 19 March 2013 18:26:15 UTC+1, MDay wrote:
hi there - hoping someone can help me with a simple issue I have having with retrieving data from an HTTP Post.   I am using mailgun to post an email message to a simple method in my application...  Everything is working correctly except I can't get attachments out of the POST.  I noticed that the encoding is set as multipart/form-data and the support guys at mailgun indicated I had to use $FILES to retrieve the data from the post.   I am a bit of a newbie, so now I am lost..

Here is what my current code looks like:

$subject = $this->request->data('subject');   //THIS WORKS

$attachement_test1 = $this->request->data($_FILES['attachment-1']);  //THIS DOESN'T WORK

$attachement_test2 = $this->request->data('attachment-1');//THIS DOESN'T WORK EITHER

$this->log("New Message");

$this->log($subject);

$this->log($attachement_test1);

$this->log($attachement_test2);


Snip from the mailgun docs:


attachment-xstringattached file ('x' stands for number of the attachment). Attachments are handled as file uploads, encoded as multipart/form-data.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: