public function setFromPost($post)
 {
     //webcam key should follow http://tools.ietf.org/html/rfc2397
     if (array_key_exists('webcam', $post) && is_string($rawdata = $post['webcam']) && substr($rawdata, 0, 5) == 'data:') {
         $rawdata = substr($rawdata, 5);
         list($mediaencoding, $data) = array_pad(explode(',', $rawdata, 2), 2, '');
         $mediaencoding = explode(';', $mediaencoding);
         $encoding = 'base64';
         $params = array();
         $mediatype = false;
         foreach ($mediaencoding as $part) {
             if (strpos($part, '/') !== false) {
                 //it is a media type
                 $mediatype = $part;
             } else {
                 if (strpos($part, '=') !== false) {
                     //it is a paramter;
                     $params[] = $part;
                 } else {
                     //it is an encoding
                     $encoding = $part;
                 }
             }
         }
         if (!$mediatype) {
             $mediatype = 'text/plain;charset=US-ASCII';
         } else {
             if (count($params) > 0) {
                 $mediatype .= ';' . implode(';', $params);
             }
         }
         if ($encoding == 'base64') {
             $data = base64_decode($data);
         } else {
             //using ASCII encoding for octets inside the   range of safe URL characters and using the standard %xx hex encoding   of URLs for octets outside that range.
             $data = urldecode($data);
         }
         $this->setFromData($data, 'webcam.png', $mediatype);
         if (!$this->tmp_key) {
             $this->setTempKey(md5($this->name . $name . rand(0, 100000)));
         }
         $this->storeInTemporaryTable();
     } else {
         parent::setFromPost($post);
     }
 }