本文整理汇总了PHP中UploadFile::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::getError方法的具体用法?PHP UploadFile::getError怎么用?PHP UploadFile::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadFile
的用法示例。
在下文中一共展示了UploadFile::getError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadImage
function uploadImage($post)
{
$jshopConfig = JSFactory::getConfig();
$dispatcher = JDispatcher::getInstance();
$upload = new UploadFile($_FILES['category_image']);
$upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
$upload->setDir($jshopConfig->image_category_path);
$upload->setFileNameMd5(0);
$upload->setFilterName(1);
if ($upload->upload()) {
$name = $upload->getName();
if ($post['old_image'] && $name != $post['old_image']) {
@unlink($jshopConfig->image_category_path . "/" . $post['old_image']);
}
@chmod($jshopConfig->image_category_path . "/" . $name, 0777);
if ($post['size_im_category'] < 3) {
if ($post['size_im_category'] == 1) {
$category_width_image = $jshopConfig->image_category_width;
$category_height_image = $jshopConfig->image_category_height;
} else {
$category_width_image = JRequest::getInt('category_width_image');
$category_height_image = JRequest::getInt('category_height_image');
}
$path_full = $jshopConfig->image_category_path . "/" . $name;
$path_thumb = $jshopConfig->image_category_path . "/" . $name;
if ($category_width_image || $category_height_image) {
if (!ImageLib::resizeImageMagic($path_full, $category_width_image, $category_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_thumb, $jshopConfig->image_quality, $jshopConfig->image_fill_color)) {
JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
saveToLog("error.log", "SaveCategory - Error create thumbail");
}
}
@chmod($jshopConfig->image_category_path . "/" . $name, 0777);
}
$category_image = $name;
$dispatcher->trigger('onAfterSaveCategoryImage', array(&$post, &$category_image, &$path_full, &$path_thumb));
} else {
$category_image = '';
if ($upload->getError() != 4) {
JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
saveToLog("error.log", "SaveCategory - Error upload image. code: " . $upload->getError());
}
}
return $category_image;
}
示例2: save
function save()
{
$jshopConfig = JSFactory::getConfig();
require_once $jshopConfig->path . 'lib/uploadfile.class.php';
JPluginHelper::importPlugin('jshoppingadmin');
$dispatcher = JDispatcher::getInstance();
$db = JFactory::getDBO();
$value_id = JRequest::getInt("value_id");
$attr_id = JRequest::getInt("attr_id");
$post = JRequest::get("post");
$attributValue = JTable::getInstance('attributValue', 'jshop');
$dispatcher->trigger('onBeforeSaveAttributValue', array(&$post));
$upload = new UploadFile($_FILES['image']);
$upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
$upload->setDir($jshopConfig->image_attributes_path);
$upload->setFileNameMd5(0);
$upload->setFilterName(1);
if ($upload->upload()) {
if ($post['old_image']) {
@unlink($jshopConfig->image_attributes_path . "/" . $post['old_image']);
}
$post['image'] = $upload->getName();
@chmod($jshopConfig->image_attributes_path . "/" . $post['image'], 0777);
} else {
if ($upload->getError() != 4) {
JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
saveToLog("error.log", "SaveAttributeValue - Error upload image. code: " . $upload->getError());
}
}
if (!$value_id) {
$query = "SELECT MAX(value_ordering) AS value_ordering FROM `#__jshopping_attr_values` where attr_id='" . $db->escape($attr_id) . "'";
$db->setQuery($query);
$row = $db->loadObject();
$post['value_ordering'] = $row->value_ordering + 1;
}
if (!$attributValue->bind($post)) {
JError::raiseWarning("", _JSHOP_ERROR_BIND);
$this->setRedirect("index.php?option=com_jshopping&controller=attributesvalues&attr_id=" . $attr_id);
return 0;
}
if (!$attributValue->store()) {
JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
$this->setRedirect("index.php?option=com_jshopping&controller=attributesvalues&attr_id=" . $attr_id);
return 0;
}
$dispatcher->trigger('onAfterSaveAttributValue', array(&$attributValue));
if ($this->getTask() == 'apply') {
$this->setRedirect("index.php?option=com_jshopping&controller=attributesvalues&task=edit&attr_id=" . $attr_id . "&value_id=" . $attributValue->value_id);
} else {
$this->setRedirect("index.php?option=com_jshopping&controller=attributesvalues&attr_id=" . $attr_id);
}
}
示例3: upload
/**
* 上传函数
*/
function upload()
{
//导入上传类
import("ORG.Net.UploadFile");
if (!empty($_FILES['file']['name'])) {
$upload = new UploadFile();
//设置属性
$upload->maxSize = 3145728;
$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg', 'txt', 'php', 'css', 'js', 'html');
$upload->savePath = $_SESSION['path'] . '/';
$upload->uploadReplace = true;
//$upload->saveRule = 'uniqid';
if (!$upload->upload()) {
$this->assign('jumpUrl', __URL__ . '/index');
$this->error('上传失败,' . $upload->getError());
} else {
$this->assign('jumpUrl', __URL__ . '/index');
$this->success('上传成功');
}
} else {
$this->assign('jumpUrl', __URL__ . '/index');
$this->error('请选择上传的文件,' . $upload->getError());
}
}
示例4: uploadFiles
function uploadFiles($product, $product_id, $post)
{
$jshopConfig = JSFactory::getConfig();
$dispatcher = JDispatcher::getInstance();
if (!isset($post['product_demo_descr'])) {
$post['product_demo_descr'] = '';
}
if (!isset($post['product_file_descr'])) {
$post['product_file_descr'] = '';
}
if (!isset($post['product_file_sort'])) {
$post['product_file_sort'] = '';
}
for ($i = 0; $i < $jshopConfig->product_file_upload_count; $i++) {
$file_demo = "";
$file_sale = "";
if ($jshopConfig->product_file_upload_via_ftp != 1) {
$upload = new UploadFile($_FILES['product_demo_file_' . $i]);
$upload->setDir($jshopConfig->demo_product_path);
$upload->setFileNameMd5(0);
$upload->setFilterName(1);
if ($upload->upload()) {
$file_demo = $upload->getName();
@chmod($jshopConfig->demo_product_path . "/" . $file_demo, 0777);
} else {
if ($upload->getError() != 4) {
JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_FILE_DEMO);
saveToLog("error.log", "SaveProduct - Error upload demo. code: " . $upload->getError());
}
}
unset($upload);
$upload = new UploadFile($_FILES['product_file_' . $i]);
$upload->setDir($jshopConfig->files_product_path);
$upload->setFileNameMd5(0);
$upload->setFilterName(1);
if ($upload->upload()) {
$file_sale = $upload->getName();
@chmod($jshopConfig->files_product_path . "/" . $file_sale, 0777);
} else {
if ($upload->getError() != 4) {
JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_FILE_SALE);
saveToLog("error.log", "SaveProduct - Error upload file sale. code: " . $upload->getError());
}
}
unset($upload);
}
if (!$file_demo && isset($post['product_demo_file_name_' . $i]) && $post['product_demo_file_name_' . $i]) {
$file_demo = $post['product_demo_file_name_' . $i];
}
if (!$file_sale && isset($post['product_file_name_' . $i]) && $post['product_file_name_' . $i]) {
$file_sale = $post['product_file_name_' . $i];
}
if ($file_demo != "" || $file_sale != "") {
$this->addToProductFiles($product_id, $file_demo, $post['product_demo_descr_' . $i], $file_sale, $post['product_file_descr_' . $i], $post['product_file_sort_' . $i]);
}
}
//Update description files
$this->productUpdateDescriptionFiles($post['product_demo_descr'], $post['product_file_descr'], $post['product_file_sort']);
}
示例5: save
function save()
{
$mainframe = JFactory::getApplication();
$jshopConfig = JSFactory::getConfig();
require_once $jshopConfig->path . 'lib/uploadfile.class.php';
$id = JRequest::getInt("id");
$productLabel = JTable::getInstance('productLabel', 'jshop');
$post = JRequest::get("post");
$lang = JSFactory::getLang();
$post['name'] = $post[$lang->get("name")];
JPluginHelper::importPlugin('jshoppingadmin');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeSaveProductLabel', array(&$post));
$upload = new UploadFile($_FILES['image']);
$upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
$upload->setDir($jshopConfig->image_labels_path);
$upload->setFileNameMd5(0);
$upload->setFilterName(1);
if ($upload->upload()) {
if ($post['old_image']) {
@unlink($jshopConfig->image_labels_path . "/" . $post['old_image']);
}
$post['image'] = $upload->getName();
@chmod($jshopConfig->image_labels_path . "/" . $post['image'], 0777);
} else {
if ($upload->getError() != 4) {
JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
saveToLog("error.log", "Label - Error upload image. code: " . $upload->getError());
}
}
if (!$productLabel->bind($post)) {
JError::raiseWarning("", _JSHOP_ERROR_BIND);
$this->setRedirect("index.php?option=com_jshopping&controller=productlabels");
return 0;
}
if (!$productLabel->store()) {
JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
$this->setRedirect("index.php?option=com_jshopping&controller=productlabels");
return 0;
}
$dispatcher->trigger('onAfterSaveProductLabel', array(&$productLabel));
if ($this->getTask() == 'apply') {
$this->setRedirect("index.php?option=com_jshopping&controller=productlabels&task=edit&id=" . $productLabel->id);
} else {
$this->setRedirect("index.php?option=com_jshopping&controller=productlabels");
}
}
示例6: multiUpload
static function multiUpload($files, $destination = null, $name = null)
{
$result = array();
if (self::isMultiFile($files)) {
$arrayFiles = self::normalizeArray($files);
$i = 0;
foreach ($arrayFiles as $value) {
$tmp = new UploadFile($value);
if ($destination !== null) {
$tmp->setDestination($destination);
}
if ($name !== null) {
$tmp->setName($name);
}
$tmp->upload();
$cod = $tmp->getError();
$errMsg = $tmp->getError_message();
$arrayRes = array($cod, $errMsg, $tmp->getDestination(), $tmp->getName() . '.' . $tmp->getExt(), $value['name']);
array_push($result, $arrayRes);
}
} else {
$tmp = new UploadFile($files);
if ($destination !== null) {
$tmp->setDestination($destination);
}
if ($name !== null) {
$tmp->setName($name);
}
$tmp->upload();
$cod = $tmp->getError();
$errMsg = $tmp->getError_message();
$arrayRes = array($cod, $errMsg, $tmp->getDestination(), $tmp->getName() . '.' . $tmp->getExt(), $value['name']);
array_push($result, $arrayRes);
}
return $result;
}
示例7: save
function save()
{
$jshopConfig = JSFactory::getConfig();
require_once $jshopConfig->path . 'lib/image.lib.php';
require_once $jshopConfig->path . 'lib/uploadfile.class.php';
$dispatcher = JDispatcher::getInstance();
$apply = JRequest::getVar("apply");
$_alias = JSFactory::getModel("alias");
$db = JFactory::getDBO();
$man = JSFactory::getTable('manufacturer', 'jshop');
$man_id = JRequest::getInt("manufacturer_id");
$post = JRequest::get("post");
$_lang = JSFactory::getModel("languages");
$languages = $_lang->getAllLanguages(1);
foreach ($languages as $lang) {
$post['name_' . $lang->language] = trim($post['name_' . $lang->language]);
if ($jshopConfig->create_alias_product_category_auto && $post['alias_' . $lang->language] == "") {
$post['alias_' . $lang->language] = $post['name_' . $lang->language];
}
$post['alias_' . $lang->language] = JApplication::stringURLSafe($post['alias_' . $lang->language]);
if ($post['alias_' . $lang->language] != "" && !$_alias->checkExistAlias1Group($post['alias_' . $lang->language], $lang->language, 0, $man_id)) {
$post['alias_' . $lang->language] = "";
JError::raiseWarning("", _JSHOP_ERROR_ALIAS_ALREADY_EXIST);
}
$post['description_' . $lang->language] = JRequest::getVar('description' . $lang->id, '', 'post', "string", 2);
$post['short_description_' . $lang->language] = JRequest::getVar('short_description_' . $lang->language, '', 'post', "string", 2);
}
if (!$post['manufacturer_publish']) {
$post['manufacturer_publish'] = 0;
}
$dispatcher->trigger('onBeforeSaveManufacturer', array(&$post));
if (!$man->bind($post)) {
JError::raiseWarning("", _JSHOP_ERROR_BIND);
$this->setRedirect("index.php?option=com_jshopping&controller=manufacturers");
return 0;
}
if (!$man_id) {
$man->ordering = null;
$man->ordering = $man->getNextOrder();
}
$upload = new UploadFile($_FILES['manufacturer_logo']);
$upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
$upload->setDir($jshopConfig->image_manufs_path);
$upload->setFileNameMd5(0);
$upload->setFilterName(1);
if ($upload->upload()) {
if ($post['old_image']) {
@unlink($jshopConfig->image_manufs_path . "/" . $post['old_image']);
}
$name = $upload->getName();
@chmod($jshopConfig->image_manufs_path . "/" . $name, 0777);
if ($post['size_im_category'] < 3) {
if ($post['size_im_category'] == 1) {
$category_width_image = $jshopConfig->image_category_width;
$category_height_image = $jshopConfig->image_category_height;
} else {
$category_width_image = JRequest::getInt('category_width_image');
$category_height_image = JRequest::getInt('category_height_image');
}
$path_full = $jshopConfig->image_manufs_path . "/" . $name;
$path_thumb = $jshopConfig->image_manufs_path . "/" . $name;
if (!ImageLib::resizeImageMagic($path_full, $category_width_image, $category_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_thumb, $jshopConfig->image_quality, $jshopConfig->image_fill_color, $jshopConfig->image_interlace)) {
JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
saveToLog("error.log", "SaveManufacturer - Error create thumbail");
}
@chmod($jshopConfig->image_manufs_path . "/" . $name, 0777);
unset($img);
}
$man->manufacturer_logo = $name;
} else {
if ($upload->getError() != 4) {
JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
saveToLog("error.log", "SaveManufacturer - Error upload image. code: " . $upload->getError());
}
}
if (!$man->store()) {
JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
$this->setRedirect("index.php?option=com_jshopping&controller=manufacturers");
return 0;
}
$dispatcher->trigger('onAfterSaveManufacturer', array(&$man));
if ($this->getTask() == 'apply') {
$this->setRedirect("index.php?option=com_jshopping&controller=manufacturers&task=edit&man_id=" . $man->manufacturer_id);
} else {
$this->setRedirect("index.php?option=com_jshopping&controller=manufacturers");
}
}
示例8: import
function avatar_upload()
{
import('CloudUploadFile');
//上传处理类
$config = array('allowExts' => array('jpg', 'jpeg', 'png'), 'savePath' => './' . C("UPLOADPATH") . "avatar/", 'maxSize' => 512000, 'saveRule' => 'uniqid');
$upload = new UploadFile($config);
//开始上传
if ($upload->upload()) {
//上传成功
$info = $upload->getUploadFileInfo();
//写入附件数据库信息
$first = array_shift($info);
$file = $first['savename'];
$_SESSION['avatar'] = $file;
$this->ajaxReturn(array("file" => $file), "上传成功!", 1, "AJAX_UPLOAD");
} else {
//上传失败,返回错误
$this->ajaxReturn(array(), $upload->getError(), 0, "AJAX_UPLOAD");
}
}
示例9: uploadFile
$cancion = new uploadFile($_FILES['cancion']);
$nombre_tipado = $privado . '_' . $usuario . '_' . $categoria . '_' . $cancion->getName();
if ($cancion->getError() === UPLOAD_ERR_OK && $cancion->getExt() === "mp3") {
$cancion->setName($nombre_tipado);
if (!$cancion->upload()) {
echo "<h2>Error: " . $cancion->getError_message() . "</h2>";
echo $cancion;
} else {
echo "<h2>Error: " . $cancion->getError_message() . "</h2>";
}
} else {
echo "<h2>No ha llegado ninguna cancion: " . $cancion->getError_message() . "</h2>";
}
if (isset($_FILES['img'])) {
$imagen = new UploadFile($_FILES['img']);
if ($imagen->getError() === UPLOAD_ERR_OK && $imagen->getExt() === "jpg") {
$imagen->setName($nombre_tipado);
if (!$imagen->upload()) {
echo "<h2>Error: " . $imagen->getError_message() . "</h2>";
}
} else {
echo "<h2>Error: " . $imagen->getError_message() . "</h2>";
}
} else {
echo "<h2>No ha subido ninguna imagen</h2>";
}
} else {
echo "<h2>No ha subido ninguna canción</h2>";
}
} else {
echo "EEEEEEEEEEEEEEEEEEEE";
示例10: save
function save()
{
$mainframe = JFactory::getApplication();
$jshopConfig = JSFactory::getConfig();
require_once $jshopConfig->path . 'lib/image.lib.php';
require_once $jshopConfig->path . 'lib/uploadfile.class.php';
JPluginHelper::importPlugin('jshoppingadmin');
$dispatcher = JDispatcher::getInstance();
$_alias = $this->getModel("alias");
$db = JFactory::getDBO();
$category = JTable::getInstance("category", "jshop");
if (!$_POST["category_id"]) {
$_POST['category_add_date'] = getJsDate();
}
if (!isset($_POST['category_publish'])) {
$_POST['category_publish'] = 0;
}
$post = JRequest::get('post');
$_lang = $this->getModel("languages");
$languages = $_lang->getAllLanguages(1);
if ($post['category_parent_id'] == $post['category_id']) {
$post['category_parent_id'] = 0;
}
$dispatcher->trigger('onBeforeSaveCategory', array(&$post));
foreach ($languages as $lang) {
$post['name_' . $lang->language] = trim($post['name_' . $lang->language]);
if ($jshopConfig->create_alias_product_category_auto && $post['alias_' . $lang->language] == "") {
$post['alias_' . $lang->language] = $post['name_' . $lang->language];
}
$post['alias_' . $lang->language] = JApplication::stringURLSafe($post['alias_' . $lang->language]);
if ($post['alias_' . $lang->language] != "" && !$_alias->checkExistAlias1Group($post['alias_' . $lang->language], $lang->language, $post['category_id'], 0)) {
$post['alias_' . $lang->language] = "";
JError::raiseWarning("", _JSHOP_ERROR_ALIAS_ALREADY_EXIST);
}
$post['description_' . $lang->language] = JRequest::getVar('description' . $lang->id, '', 'post', "string", 2);
$post['short_description_' . $lang->language] = JRequest::getVar('short_description_' . $lang->language, '', 'post', "string", 2);
}
if (!$category->bind($post)) {
JError::raiseWarning("", _JSHOP_ERROR_BIND);
$this->setRedirect("index.php?option=com_jshopping&controller=categories");
return 0;
}
$edit = $category->category_id;
$upload = new UploadFile($_FILES['category_image']);
$upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
$upload->setDir($jshopConfig->image_category_path);
$upload->setFileNameMd5(0);
$upload->setFilterName(1);
if ($upload->upload()) {
$name = $upload->getName();
if ($post['old_image'] && $name != $post['old_image']) {
@unlink($jshopConfig->image_category_path . "/" . $post['old_image']);
}
@chmod($jshopConfig->image_category_path . "/" . $name, 0777);
if ($post['size_im_category'] < 3) {
if ($post['size_im_category'] == 1) {
$category_width_image = $jshopConfig->image_category_width;
$category_height_image = $jshopConfig->image_category_height;
} else {
$category_width_image = JRequest::getInt('category_width_image');
$category_height_image = JRequest::getInt('category_height_image');
}
$path_full = $jshopConfig->image_category_path . "/" . $name;
$path_thumb = $jshopConfig->image_category_path . "/" . $name;
if (!ImageLib::resizeImageMagic($path_full, $category_width_image, $category_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_thumb, $jshopConfig->image_quality, $jshopConfig->image_fill_color)) {
JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
saveToLog("error.log", "SaveCategory - Error create thumbail");
}
@chmod($jshopConfig->image_category_path . "/" . $name, 0777);
unset($img);
}
$category->category_image = $name;
} else {
if ($upload->getError() != 4) {
JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
saveToLog("error.log", "SaveCategory - Error upload image. code: " . $upload->getError());
}
}
$this->_reorderCategory($category);
if (!$category->store()) {
JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
$this->setRedirect("index.php?option=com_jshopping&controller=categories");
return 0;
}
$dispatcher->trigger('onAfterSaveCategory', array(&$category));
$success = $edit ? _JSHOP_CATEGORY_SUCC_UPDATE : _JSHOP_CATEGORY_SUCC_ADDED;
if ($this->getTask() == 'apply') {
$this->setRedirect('index.php?option=com_jshopping&controller=categories&task=edit&category_id=' . $category->category_id, $success);
} else {
$this->setRedirect('index.php?option=com_jshopping&controller=categories', $success);
}
}