本文整理汇总了PHP中SaeStorage::errmsg方法的典型用法代码示例。如果您正苦于以下问题:PHP SaeStorage::errmsg方法的具体用法?PHP SaeStorage::errmsg怎么用?PHP SaeStorage::errmsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SaeStorage
的用法示例。
在下文中一共展示了SaeStorage::errmsg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaeStorage
/**
* 用flash添加照片
*/
function add_photo()
{
if ($_FILES) {
global $php;
$php->upload->thumb_width = 136;
$php->upload->thumb_height = 136;
$php->upload->max_width = 500;
$php->upload->max_height = 500;
$php->upload->thumb_qulitity = 100;
if (class_exists('SaeStorage', false)) {
$s = new SaeStorage();
$file_id = uniqid('pic_', false) . mt_rand(1, 100);
$tmp_file = SAE_TMP_PATH . '/thum_' . $file_id . '.jpg';
Image::thumbnail($_FILES['Filedata']['tmp_name'], $tmp_file, $php->upload->thumb_width, $php->upload->thumb_height, $php->upload->thumb_qulitity, false);
$pic = '/uploads/' . $file_id . ".jpg";
$ret = $s->upload('static', $pic, $_FILES['Filedata']['tmp_name']);
if ($ret) {
$data['picture'] = $s->getUrl('static', $pic);
} else {
echo $s->errmsg() . ' : ' . $s->errno();
return;
}
$thum_pic = '/uploads/thum_' . $file_id . '.jpg';
$ret = $s->upload('static', $thum_pic, $tmp_file);
if ($ret) {
$data['imagep'] = $s->getUrl('static', $thum_pic);
} else {
echo $s->errmsg() . ' : ' . $s->errno();
return;
}
} else {
$php->upload->sub_dir = 'user_images';
$up_pic = Swoole::$php->upload->save('Filedata');
if (empty($up_pic)) {
return '上传失败,请重新上传! Error:' . $php->upload->error_msg;
}
$data['picture'] = $up_pic['name'];
$data['imagep'] = $up_pic['thumb'];
}
$data['uid'] = $_POST['uid'];
$up_pic['photo_id'] = $this->swoole->model->UserPhoto->put($data);
/* if(isset($_POST['post']))
{
Api::feed('photo', $data['uid'], 0, $up_pic['photo_id']);
} */
return json_encode($up_pic);
} else {
$this->swoole->tpl->display('myphoto_add_photo.html');
}
}
示例2: upradio
static function upradio($radio)
{
$s = new SaeStorage();
$mname = $_FILES[$radio]['name'];
$msize = $_FILES[$radio]['size'];
if ($mname != "") {
if ($msize > 10240000) {
echo '图片大小不能超过10M';
exit;
}
$type = strstr($mname, '.');
if ($type != ".mp3") {
echo '对不起!只支持mp3格式,如果是这几种格式请去掉处文件标识符以外的点"."';
exit;
}
if (!$_FILES[$radio]['name']) {
die('没有选择文件!');
}
//上传文件校验,可以添加文件类型等检验、此处简略处理
$file_name = "m_" . time() . rand(100, 999);
//定义保存的文件名称
$m_path = $file_name . $type;
//要保存的文件路径+文件名,此处保存在根目录下
$link = $s->upload('upcon', $m_path, $_FILES[$radio]['tmp_name']);
if ($link) {
$out_radio = array('m_name' => $file_name, 'm_url' => $link);
echo json_encode($out_radio);
} else {
$emsg = $s->errmsg();
$this->writelog_debug($emsg);
die('上传零时文件失败!');
}
}
}
示例3: submit
function submit()
{
//var_dump($_FILES);exit;
if (!$this->has_privilege()) {
$this->json->output(array('success' => false, 'm' => '您没有使用该功能的权限'));
}
$proj_id = $this->input->post('proj_id');
if (!$this->utility->chk_id($proj_id)) {
$this->json->output(array('success' => false, 'm' => '输入的记录编号错误'));
}
$max_size = 10;
// filesize MB
if ($_FILES['file']['size'] > $max_size * 1024 * 1024) {
$this->json->output(array('success' => false, 'm' => '上传文件大小不能超过' . $max_size . 'MB'));
}
if (!empty($_FILES)) {
$s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY);
$url = $s->upload('upload', $_FILES['file']['name'], $_FILES['file']['tmp_name']);
if (!$url) {
$this->json->output(array('success' => false, 'm' => $s->errmsg()));
}
// insert into upload table
$id = $this->Proj_model->create_upload($proj_id, $_FILES['file']['name'], $_FILES['file']['size']);
// extjs json decode bug, using echo instead of output
// $this->json->output(array('success' => true, 'url' => $url));
echo '{"success":true, "file":"' . $_FILES['file']['name'] . '"}';
exit;
}
}
示例4: upload_mp3
function upload_mp3($filePath, $fileName)
{
$stor = new SaeStorage();
$stor->upload(SAE_DOMAIN, $fileName, $filePath);
$errmsg = $stor->errmsg();
//var_export($errmsg);
if ($errmsg == 0) {
$result['success'] = 1;
$result['url'] = $stor->getUrl(SAE_DOMAIN, $fileName);
} else {
$result['success'] = -1;
}
return $result;
}
示例5: save
/**
* 保存指定文件
* @param array $file 保存的文件信息
* @param boolean $replace 同名文件是否覆盖
* @return boolean 保存状态,true-成功,false-失败
*/
public function save($file, $replace = true)
{
$filename = ltrim($this->rootPath . '/' . $file['savepath'] . $file['savename'], '/');
$st = new \SaeStorage();
/* 不覆盖同名文件 */
if (!$replace && $st->fileExists($this->domain, $filename)) {
$this->error = '存在同名文件' . $file['savename'];
return false;
}
/* 移动文件 */
if (!$st->upload($this->domain, $filename, $file['tmp_name'])) {
$this->error = '文件上传保存错误![' . $st->errno() . ']:' . $st->errmsg();
return false;
}
return true;
}
示例6: handleFiles
function handleFiles($typeId, $tmpNames, $names)
{
global $IS_SAE;
$result = array("success" => true, "details" => array());
$ext_arr = array();
for ($i = 0; $i < count($names); $i++) {
$tmp = explode(".", $names[$i]);
$tmp = $tmp[count($tmp) - 1];
array_push($ext_arr, $tmp);
}
// when name the folder, here we wipe the parameter $type.
$directory = "../resources/chart/{$typeId}/";
if ($IS_SAE) {
$st = new SaeStorage();
$attr = array('encoding' => 'gzip');
for ($i = 0; $i < count($names); $i++) {
$tName = $tmpNames[$i];
$oName = $names[$i];
$file_new_name = date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT) . "." . $ext_arr[$i];
$uploadRes = $st->upload($_SERVER['HTTP_APPNAME'], $file_new_name, $_FILES['photo']['tmp_name'][$i], $attr, true);
if ($uploadRes === false) {
array_push($result["details"], array("success" => false, "msg" => "图片'{$oName}'上传失败!error:" . $st->errno() . ' ' . $st->errmsg(), "file" => '', "original_file_name" => $oName));
} else {
array_push($result["details"], array("success" => true, "msg" => "图片'{$oName}'上传成功!重命名为'{$file_new_name}'。", "file" => $uploadRes, "original_file_name" => $oName));
}
}
} else {
if (!file_exists($directory)) {
if (!mkdir($directory)) {
throw new Exception("文件夹创建失败!" . $directory);
}
}
for ($i = 0; $i < count($names); $i++) {
$tName = $tmpNames[$i];
$oName = $names[$i];
$file_new_name = date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT) . "." . $ext_arr[$i];
if (move_uploaded_file($tName, $directory . $file_new_name)) {
array_push($result["details"], array("success" => true, "msg" => "图片'{$oName}'上传成功!重命名为'{$file_new_name}'。", "file" => $directory . $file_new_name, "original_file_name" => $oName));
} else {
array_push($result["details"], array("success" => false, "msg" => "图片'{$oName}'上传失败!", "file" => '', "original_file_name" => $oName));
}
}
}
return $result;
}
示例7: save
}
/**
* 保存指定文件
* @param array $file 保存的文件信息
* @param boolean $replace 同名文件是否覆盖
* @return boolean 保存状态,true-成功,false-失败
*/
public function save(&$file, $replace = true)
{
$filename = ltrim($this->rootPath . '/' . $file['save_path'] . $file['save_name'], '/');
$st = new \SaeStorage();
/* 不覆盖同名文件 */
if (!$replace && $st->fileExists($this->domain, $filename)) {
$this->error = '存在同名文件' . $file['savename'];
return false;
}
/* 移动文件 */
if (!$st->upload($this->domain, $filename, $file['tmp_name'])) {
$this->error = '文件上传保存错误![' . $st->errno() . ']:' . $st->errmsg();
示例8: submit
function submit()
{
//var_dump($_FILES);exit;
if (!$this->has_privilege()) {
$this->json->output(array('success' => false, 'm' => '您没有使用该功能的权限'));
}
$remark = $this->input->post('remark');
$dir_path = $this->input->post('dir_path');
//if(!$this->utility->chk_id($proj_id)) {
// $this->json->output(array('success' => false, 'm' => '输入的记录编号错误'));
//}
$max_size = 20;
// filesize MB
if ($_FILES['file']['size'] > $max_size * 1024 * 1024) {
$this->json->output(array('success' => false, 'm' => '上传文件大小不能超过' . $max_size . 'MB'));
}
$store_filename = $this->encrypt->sha1($_FILES['file']['name'] . date('Y-m-d H:i:s'));
if (!empty($_FILES)) {
$s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY);
$url = $s->upload('library', $store_filename, $_FILES['file']['tmp_name']);
if (!$url) {
$this->json->output(array('success' => false, 'm' => $s->errmsg()));
}
// insert into upload table
$file_list = $this->Library_model->get_upload_by_name($_FILES['file']['name'], $dir_path, 'normal');
$version = 1;
if (count($file_list) > 1) {
echo '{"success":false}';
exit;
} else {
if (count($file_list) == 1) {
$version = $file_list[0]->version;
}
}
$id = $this->Library_model->create_upload($remark, $_FILES['file']['name'], $_FILES['file']['size'], $dir_path, '', $store_filename, $version);
// extjs json decode bug, using echo instead of output
// $this->json->output(array('success' => true, 'url' => $url));
echo '{"success":true, "file":"' . $_FILES['file']['name'] . '"}';
exit;
}
}
示例9: define
static function upload_topic($pic_name, $change = 0, $oldpic = null)
{
define('DOMAIN', 'upload');
//要上传的storage名称定义
$temp = 'temp';
$s = new SaeStorage();
$poc = array('_big.jpg', '_midde.jpg', '_small.jpg', '.jpg');
foreach ($poc as $p) {
$pic = $pic_name . $p;
$img = $s->read($temp, $pic);
if ($s->write(DOMAIN, $pic, $img) == false) {
echo "图片写入失败!请重新上传,如果还是失败请联系客服!但是不要放弃对咱们原创的希望";
var_dump($s->errno(), $s->errmsg());
}
unset($pic);
unset($pics);
unset($img);
}
self::delete_topic($pic_name);
if ($change == 1) {
self::delete_topic($oldpic, 'jpg', 'upload');
}
unset($s);
return 1;
}
示例10: alert
//在非云端运行,执行保存文件操作
if (!isset($_SERVER['HTTP_APPNAME'])) {
//移动文件
$file_path = $save_path . $new_file_name;
if (move_uploaded_file($tmp_name, $file_path) === false) {
alert("上传文件失败。");
}
@chmod($file_path, 0644);
$file_url = $save_url . $new_file_name;
} else {
//在云端运行,运用 SaeStorage 进行文件保存
$sae_file = new SaeStorage();
$sae_url = $sae_file->upload('yikeup', $new_file_name, $tmp_name);
if (!$sae_url) {
//出现错误
alert(SaeStorage::errmsg());
}
$file_url = $sae_url;
}
//header('Content-type: text/html; charset=UTF-8');
$json = new Services_JSON();
echo $json->encode(array('error' => 0, 'url' => $file_url));
exit;
}
function alert($msg)
{
//header('Content-type: text/html; charset=UTF-8');
$json = new Services_JSON();
echo $json->encode(array('error' => 1, 'message' => $msg));
exit;
}
示例11: upload
/**
* 上传头像
*/
function upload($_FILES)
{
$username = $_GET['username'];
$files = $_FILES['file'];
$filename = $files['name'];
//获取图片名字
$fileResource = $files['tmp_name'];
$storage = new SaeStorage();
$domain = "userinfo";
if ($storage->fileExists($domain, $filename)) {
$storage->delete($domain, $filename);
}
if ($storage->upload($domain, $filename, $fileResource)) {
$imgUrl = $storage->getCDNUrl($domain, $filename);
//获取图片地址
//执行修改语句,将图片URl地址及图片名字写入数据库
$update = "update `user` set `imgName`='{$filename}', `imgUrl`='{$imgUrl}' where `username`='{$username}'";
$result = mysql_query($update);
//if(mysql_affected_rows()!=0){
echo "上传成功";
//}
} else {
echo "上传失败,错误信息:" . $storage->errmsg();
}
}
示例12: file_read
/**
* 读文件
*
* @access public
* @param string
* @return string/bytes
*/
public function file_read($path = '')
{
$content = $this->_storage->read($this->_config['storage'], $this->_translate_path($path));
if ($content == FALSE) {
show_error(SaeStorage::errmsg());
}
return $content;
}
示例13: SaeStorage
<?php
// 参考: http://apidoc.sinaapp.com/class-SaeStorage.html
// 顺便吐槽下,居然没有 createDomain() 的接口,需要开发者手工创建一个 upload 的 domain
// 虽然 SAE 很有争议,但是还是有很多开发者想玩一玩,XN3 只需要一个文件配置文件就搞定。正式运营环境建议使用 VPS 或者独立服务器。
if (IN_SAE) {
$saestorage = new SaeStorage();
//$saestorage->setDomainAttr('domain', array('private'=>'false'));
$n = $saestorage->getDomainCapacity('upload');
//if($n == NULL || $saestorage->errno() == -7) exit('SaeStorage upload 磁盘配额不足!');
if ($n == NULL || $saestorage->errno()) {
exit($saestorage->errmsg());
}
$conf['db'] = array('type' => 'mysql', 'mysql' => array('master' => array('host' => SAE_MYSQL_HOST_M . (SAE_MYSQL_PORT == 3306 ? '' : ':' . SAE_MYSQL_PORT), 'user' => SAE_MYSQL_USER, 'password' => SAE_MYSQL_PASS, 'name' => SAE_MYSQL_DB, 'charset' => 'utf8', 'engine' => 'MyISAM'), 'slaves' => array()));
$conf['upload_url'] = $saestorage->geturl('upload', '') . '/';
$conf['upload_path'] = 'saestor://upload/';
$conf['tmp_path'] = SAE_TMP_PATH;
}
// 函数如果放在 if 里面不利于 opcode 缓存。
/*function sae_move_upload_file($srcfile, $destfile) {
global $saestorage;
return $saestorage->upload('upload', $srcfile, $destfile);
}*/
示例14: SaeStorageErrorMessage
function SaeStorageErrorMessage()
{
//无错误则为'Success'
$storage = new SaeStorage();
$result = $storage->errmsg();
return $result;
}
示例15: user_update_avatar
/**
* 用户更新头像
*
* 使用标准Form表单上传,头像文件名为file,只接受jpg格式的文件
*
* @param string token , 必填
* @return user array
* @author EasyChen
*/
public function user_update_avatar()
{
if ($_FILES['file']['error'] != 0) {
return self::send_error(OP_API_UPLOAD_ERROR, 'UPLOAD ERROR ' . $_FILES['file']['error']);
}
$tmp_image_name = SAE_TMP_PATH . md5(time() . rand(1, 99999)) . '.tmp.jpg';
jpeg_up($_FILES['file']['tmp_name'], $tmp_image_name);
include_once AROOT . 'lib/thumbnail.class.php';
$file_thumb_name = 'avatar-' . uid() . '.jpg';
$tmp_file = SAE_TMP_PATH . $file_thumb_name;
include_once AROOT . 'lib/icon.class.php';
$icon = new Icon();
$icon->path = $tmp_image_name;
$icon->size = 100;
$icon->dest = $tmp_file;
$icon->createIcon();
if (on_sae()) {
$s = new SaeStorage();
if (!($thumb_url = $s->write('upload', $file_thumb_name, file_get_contents($tmp_file)))) {
return self::send_error(OP_API_STORAGE_ERROR, 'SAVE ERROR ' . $s->errmsg());
}
} else {
$local_storage = AROOT . 'static' . DS . 'upload' . DS . 'avatar' . DS;
$local_storage_url = c('site_url') . DS . 'static' . DS . 'upload' . DS . 'avatar' . DS;
$thumb_path = $local_storage . $file_thumb_name;
$thumb_url = $local_storage_url . $file_thumb_name;
if (!copy($tmp_file, $thumb_path)) {
return self::send_error(OP_API_STORAGE_ERROR, 'SAVE ERROR ');
}
}
$sql = "UPDATE `user` SET `avatar_small` = '" . s($thumb_url) . "' WHERE `id` = '" . intval(uid()) . "' LIMIT 1";
run_sql($sql);
if (mysql_errno() != 0) {
return self::send_error(OP_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
} else {
return self::send_result(get_user_info_by_id(intval(uid())));
}
}