try { switch ($_FILES['us_signature']['type']) { case 'image/gif': $ext = 'gif'; break; case 'image/jpg': case 'image/jpeg': case 'image/pjpeg': $ext = 'jpg'; break; case 'image/png': $ext = 'png'; break; } $resizedFile = R3_TMP_DIR . md5(microtime()) . ".{$ext}"; pSimplePhoto::CreateThumb($_FILES['us_signature']['tmp_name'], $resizedFile, 350, 350, true, false); $file = file_get_contents($resizedFile); $mime = $_FILES['us_signature']['type']; $data = array($file, $mime); $sql = "UPDATE auth.users SET " . " us_signature=?, " . " us_signature_mime=? " . "WHERE " . " us_id=" . $auth->getUID(); $sth = $mdb2->prepare($sql, array('blob', 'text')); $affectedRows = $sth->execute($data); $ret['status'] = R3_REQUEST_OK; $ret['random'] = md5(microtime()); echo json_encode($ret); die; } catch (Exception $e) { if ($_FILES['us_signature']['error'] != 0) { $ret['status'] = R3_REQUEST_ERROR; $ret['error'] = _('Unknown Error.'); echo json_encode($ret);
/** * Add a file * param string $orgName the original file name with extension * param string $type the type (1st folder. Eg: document) * param string $kind the kind (2st folder. Eg: building) * param integer $id the file id (doc_file_id) * param string $fsName the filesistem name ($_FILES[...][tmp_name]) */ public function removeOldFile($orgName, $type, $kind, $id) { require_once R3_LIB_DIR . 'simplephoto.php'; $path = ''; if ($type != '') { $path .= $type . '/'; } if ($kind != '') { $path .= $kind . '/'; } $doc = new pSimplePhoto(R3_UPLOAD_DIR . $path, ''); return $doc->DeletePhoto($id, $orgName); }