Exemple #1
0
 public function editorupload()
 {
     $CRUD_AUTH = $this->session->userdata('CRUD_AUTH');
     if (empty($CRUD_AUTH)) {
         exit;
     }
     if (isset($_GET['CKEditorFuncNum'])) {
         require FCPATH . '/application/third_party/scrud/class/FileUpload.php';
         $msg = '';
         // Will be returned empty if no problems
         $callback = $_GET['CKEditorFuncNum'];
         // Tells CKeditor which function you are executing
         $fileUpload = new FileUpload();
         $fileUpload->uploadDir = __IMAGE_UPLOAD_REAL_PATH__;
         $fileUpload->extensions = array('.bmp', '.jpeg', '.jpg', '.png', '.gif');
         $fileUpload->tmpFileName = $_FILES['upload']['tmp_name'];
         $fileUpload->fileName = $_FILES['upload']['name'];
         $fileUpload->httpError = $_FILES['upload']['error'];
         if ($fileUpload->upload()) {
             $image_url = __MEDIA_PATH__ . "images/" . $fileUpload->newFileName;
         }
         $error = $fileUpload->getMessage();
         if (!empty($error)) {
             $msg = 'error : ' . implode("\n", $error);
         }
         $output = '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(' . $callback . ', "' . $image_url . '","' . $msg . '");</script>';
         echo $output;
     }
 }
function upload()
{
    $path = "./uploads/";
    //设置图片上传路径
    $up = new FileUpload($path);
    //创建文件上传类对象
    if ($up->upload('pic')) {
        //上传图片
        $filename = $up->getFileName();
        //获取上传后的图片名
        $img = new Image($path);
        //创建图像处理类对象
        $img->thumb($filename, 300, 300, "");
        //将上传的图片都缩放至在300X300以内
        $img->thumb($filename, 80, 80, "icon_");
        //缩放一个80x80的图标,使用icon_作前缀
        $img->watermark($filename, "logo.gif", 5, "");
        //为上传的图片加上图片水印
        return array(true, $filename);
        //如果成功返回成功状态和图片名称
    } else {
        return array(false, $up->getErrorMsg());
        //如果失败返回失败状态和错误消息
    }
}
 private static function editCuadro($gestor, $sesion)
 {
     $obra = new Obra();
     $obra->read();
     $pkID = Request::post("pkID");
     $nombre = Request::post("nombre");
     $email = Request::post('email');
     $usuario = $sesion->getUser();
     $obra->setId_usuario($usuario);
     /*Subir fotografia*/
     $subir = new FileUpload("nuevaImagen");
     $subir->setDestino("../../controlUsuario/cuadros/{$usuario}/");
     $subir->setTamaño(100000000);
     $subir->setNombre($nombre);
     $subir->setPolitica(FileUpload::REEMPLAZAR);
     if ($subir->upload()) {
         echo 'Archivo subido con éxito';
         $obra->setImagen($nombre . "." . $subir->getExtension());
     } else {
         echo 'Archivo no subido';
     }
     $obra->setImagen($nombre . "." . $subir->getExtension());
     $r = $gestor->set($obra, $pkID);
     echo $r;
     //header("Location:index.php?op=edit&r=$r");
 }
 function m_updateCompInfo()
 {
     if (!isset($this->request['bill_state_id']) || empty($this->request['bill_state_id'])) {
         $this->request['bill_state_id'] = "";
     } else {
         $this->request['bill_state'] = "";
     }
     #FILE UPLOADING START
     if ($this->libFunc->checkImageUpload("image1") && $_FILES["image1"]["tmp_name"] != "") {
         $fileUpload = new FileUpload();
         $fileUpload->source = $_FILES["image1"]["tmp_name"];
         $fileUpload->target = $this->imagePath . "company/" . $_FILES["image1"]["name"];
         $newName1 = $fileUpload->upload();
         $fileUpload->resampleImage($this->imagePath . "company/" . $newName1, 250, 250, 100);
         // [/DRK]
         if ($newName1 != false) {
             $image1 = $newName1;
         }
     } else {
         $this->obDb->query = "SELECT vLogo FROM " . COMPANYSETTINGS;
         $logo = $this->obDb->fetchQuery();
         $image1 = $logo[0]->vLogo;
     }
     #INSERTING COMPANY DETAILS
     $this->obDb->query = "UPDATE " . COMPANYSETTINGS . " SET \n\t\tvCname ='" . $this->libFunc->m_addToDB($this->request['storeName']) . "',\n\t\tvAddress ='" . $this->libFunc->m_addToDB($this->request['storeAddress']) . "',\n\t\tvCity ='" . $this->libFunc->m_addToDB($this->request['storeCity']) . "',\n\t\tvState='" . $this->libFunc->m_addToDB($this->request['bill_state_id']) . "',\n\t\tvStateName='" . $this->libFunc->m_addToDB($this->request['bill_state']) . "',\n\t\tvCountry='" . $this->libFunc->m_addToDB($this->request['bill_country_id']) . "',\n\t\tvZip='" . $this->libFunc->m_addToDB($this->request['storeZip']) . "',\n\t\tvFax  ='" . $this->libFunc->m_addToDB($this->request['storeFax']) . "',\n\t\tvPhone ='" . $this->libFunc->m_addToDB($this->request['storePhone']) . "',\n\t\tvFreePhone  ='" . $this->libFunc->m_addToDB($this->request['storeTollFree']) . "',\n\t\tvVatNumber  ='" . $this->libFunc->m_addToDB($this->request['vatNumber']) . "',\n\t\tvRNumber  ='" . $this->libFunc->m_addToDB($this->request['companyNumber']) . "',\n\t\tvSlogan  ='" . $this->libFunc->m_addToDB($this->request['companySlogan']) . "',\n\t\tvLogo  ='" . $image1 . "'";
     $this->obDb->updateQuery();
     $this->libFunc->m_mosRedirect(SITE_URL . "admin/adminindex.php?action=settings.company&msg=1");
 }
Exemple #5
0
 public function preform()
 {
     $uploadFile = new FileUpload();
     $uploadFile->set("maxsize", 2000000);
     $uploadFile->set("allowtype", array("gif", "png", "jpg", "jpeg"));
     $uploadFile->set("israndname", true);
     if ($this->params['safe']['type'] == "addArticle") {
         $path = "../uploadfile/article/" . $this->params['safe']['fenlei_id'] . "/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('fm_img')) {
             $data = array('uid' => 1, 'title' => $this->params['safe']['title'], 'contents' => $this->params['safe']['contents'], 'fenlei_id' => $this->params['safe']['fenlei_id'], 'fm_img' => $path . $uploadFile->getFileName(), 'time' => time());
             $DaoArticle = new DaoArticle();
             $DaoArticle->insertArticle($data);
         } else {
             //获取上传失败以后的错误提示
             throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
         }
     } elseif ($this->params['safe']['type'] == "addUser") {
         $path = "../uploadfile/user_img/" . $this->params['safe']['user_name'] . "/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('user_img')) {
             $data = array('user_name' => $this->params['safe']['user_name'], 'user_nickname' => $this->params['safe']['user_nickname'], 'user_password' => md5($this->params['safe']['password']), 'user_qm' => "这家伙还没写签名呢!", 'user_img' => $path . $uploadFile->getFileName(), 'user_inTime' => time());
             $DaoUser = new DaoUser();
             $DaoUser->addUser($data);
         } else {
             //获取上传失败以后的错误提示
             throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
         }
     } elseif ($this->params['safe']['type'] == "addfenlei") {
         $path = "../uploadfile/Fenlei/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('fenlei_img')) {
             $data = array('name' => $this->params['safe']['name'], 'time' => time(), 'fenlei_img' => $path . $uploadFile->getFileName());
             $DaoFenlei = new DaoFenlei();
             $DaoFenlei->addFenlei($data);
         }
     }
 }
 function m_uploadImage()
 {
     $fileUpload = new FileUpload();
     $libFunc = new c_libFunctions();
     $this->obDb->query = "select iVendorid_PK,vImage from " . SUPPLIERS . " where iVendorid_PK = " . $this->request['id'];
     $row_code = $this->obDb->fetchQuery();
     if ($this->libFunc->checkImageUpload("image")) {
         $fileUpload->source = $_FILES["image"]["tmp_name"];
         $fileUpload->target = $this->imagePath . "suppliers/" . $_FILES["image"]["name"];
         $newName1 = $fileUpload->upload();
         if ($newName1 != false) {
             $image = $newName1;
         }
         if (!empty($row_code[0]->vImage)) {
             $fileUpload->deleteFile($this->imagePath . "suppliers/" . $row_code[0]->vImage);
         }
         $imagename = "image";
     } else {
         $image = $row_code[0]->vImage;
     }
     $this->obDb->query = "UPDATE " . SUPPLIERS . " SET `vImage`='{$image}', `tmEditDate`='" . time() . "', `iAdminUser` ='" . $_SESSION['uid'] . "' where iVendorid_PK ='" . $this->request['id'] . "'";
     $this->obDb->updateQuery();
     $this->libFunc->m_mosRedirect(SITE_URL . "user/adminindex.php?action=supplier.uploadForm&status=1&id=" . $this->request['id']);
 }
Exemple #7
0
<?php

require '../clases/AutoCarga.php';
$sesion = new Session();
$archivo = Request::post("archivo");
$nombre = Request::post("nombre");
var_dump($nombre);
var_dump($archivo);
$artista = $sesion->getUser();
$carpeta = "../images/" . $artista->getEmail();
$subir = new FileUpload("archivo");
if (!file_exists($carpeta)) {
    mkdir($carpeta, 0777);
}
$subir->upload();
//$sesion->sendRedirect("index.php");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$uploader = new FileUpload();
//用于断点续传,验证指定分块是否已经存在,避免重复上传
if (isset($_POST['status'])) {
    if ($_POST['status'] == 'chunkCheck') {
        $target = '../uploads/' . $_POST['name'] . '/' . $_POST['chunkIndex'];
        if (file_exists($target) && filesize($target) == $_POST['size']) {
            die('{"ifExist":1}');
        }
        die('{"ifExist":0}');
    } elseif ($_POST['status'] == 'md5Check') {
        //todo 模拟持久层查询
        $dataArr = array('b0201e4d41b2eeefc7d3d355a44c6f5a' => 'kazaff2.jpg');
        if (isset($dataArr[$_POST['md5']])) {
            die('{"ifExist":1, "path":"' . $dataArr[$_POST['md5']] . '"}');
        }
        die('{"ifExist":0}');
    } elseif ($_POST['status'] == 'chunksMerge') {
        if ($path = $uploader->chunksMerge($_POST['name'], $_POST['chunks'], $_POST['ext'])) {
            //todo 把md5签名存入持久层,供未来的秒传验证
            die('{"status":1, "path": "' . $path . '"}');
        }
        die('{"status":0');
    }
}
if (($path = $uploader->upload('file', $_POST)) !== false) {
    die('{"status":1, "path": "' . $path . '"}');
}
die('{"status":0}');
 function upload($path = '')
 {
     $path = $this->BaseUrl . '/' . trim($path, '/');
     if (!is_dir($path)) {
         $data['error'] = 'Folder ' . $path . ' does not exist.';
         return $data;
     }
     $up = new FileUpload();
     //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
     $up->set("path", $path);
     $up->set("maxsize", 8 * 1024 * 1024);
     if (!empty($this->allowType) && $this->allowType != '*') {
         $up->set("allowtype", explode(',', $this->allowType));
     }
     $up->set("israndname", false);
     if ($up->upload("upfile")) {
         return $up->getFileName();
     } else {
         $data['error'] = $up->getErrorMsg();
     }
     /**/
     return $data;
 }
 private static function insertArt()
 {
     $sesion = new Session();
     if ($sesion->isLogged()) {
         $db = new DataBase();
         $manager = new ManageArt($db);
         $managerUser = new ManageUser($db);
         $email = Request::post("email");
         $title = Request::post("title");
         $usuario = $managerUser->get($email);
         $art = new Art();
         $art->setEmail($email);
         $art->setTitle($title);
         $art->setCdate(date('Y-m-d G:i:s'));
         $fecha = date('_Y_m_d_G_i_s');
         $photo = new FileUpload("image");
         if ($photo->getError() === false) {
             $art->setImage("./resources/art/" . $usuario->getAlias() . $fecha . ".jpg");
             $photo->setDestination("./resources/art/");
             $photo->setName($usuario->getAlias() . $fecha);
             $photo->upload();
         }
         $manager->insert($art);
         $db->close();
     }
     self::viewProfile();
 }
Exemple #11
0
    ?>
            <br/>
            <div class="foto" id="fotopersonal"><img src="../images/<?php 
    echo $foto;
    ?>
.jpg" id='imagep'/></div><br/><br/>
            <form method="post" action="#" enctype="multipart/form-data"/><br/><br/>
            <input type="file" name="imagen" value="Editar imagen"/><br/><br/>
            <input type="submit" name="enviar" value="Subir" class="enviar" />
            </form>
            <?php 
    $trozo = $usuario->getTrozo($em);
    $fileUpload = new FileUpload($_FILES["imagen"]);
    $fileUpload->setNombre($trozo);
    $fileUpload->setDestino("../images/");
    $fileUpload->upload();
    ?>
        </div>
        
        <div class="capafoto">
        <h2 class="tb"> MI PERFIL</h2>
        
        <table>
        <form method="POST" action="../oauth/modificar.php">
        <tr><td>Email:</td><td> <input type="text" name="email" value=" <?php 
    echo $usuario->getEmail();
    ?>
 "/></td>
        <tr><td>Alias:</td><td><?php 
    echo $em;
    ?>
 function m_uploadImages()
 {
     $fileUpload = new FileUpload();
     foreach ($_FILES["image"]["name"] as $key => $val) {
         if ($_FILES["image"]["name"][$key] != "") {
             $fileUpload->source = $_FILES["image"]["tmp_name"][$key];
             $fileUpload->target = $this->imagePath . "options/" . $_FILES["image"]["name"][$key];
             $image[] = $fileUpload->upload();
         } else {
             $image[] = 0;
         }
     }
     return $image;
 }
 private static function insertSet()
 {
     $bd = new BaseDatos();
     $gestor_galeria = new ManageGallery($bd);
     $sesion = new Session();
     $artista = self::getArtist($sesion);
     $descripcion = Request::post("descripcion");
     $id = Request::post("id");
     $file = new FileUpload("imagen");
     var_dump($gestor_galeria->count());
     $nombre = $artista->getGaleria() . "_" . ($gestor_galeria->count() + 1) . sha1($file->getNombre());
     $file->setNombre($nombre);
     $file->setDestino("../img/");
     $file->setTamanio(52428800);
     $file->getPolitica(FileUpload::RENOMBRAR);
     $file->addTipo("gif");
     $file->upload();
     $imagen_ruta = "../img/" . $file->getNombre() . "." . $file->getExtension();
     $gallery = new Gallery($id, 0, $imagen_ruta, $descripcion);
     $r = $gestor_galeria->insert($gallery);
     header("Location:?op=insert&r={$r}&action=read&do=View#section3");
 }
Exemple #14
0
<?php

require 'clases/Request.php';
require 'clases/FileUpload.php';
require 'clases/Session.php';
require 'clases/Server.php';
$sesion = new Session();
$user = $sesion->get("usuario");
$usuario = Request::post("usuario1");
$categoria = Request::post("categoria1");
$cancion = new FileUpload("cancion");
$cancion->setDestino("canciones/");
$cancion->setNombre($user . "_" . $categoria . "_" . $cancion->getNombre());
$cancion->setPolitica(FileUpload::RENOMBRAR);
$cancion->upload();
$imagen = new FileUpload("imagen");
$imagen->setDestino("canciones/");
$imagen->setNombre($cancion->getNombre());
$imagen->setPolitica(FileUpload::RENOMBRAR);
$imagen->upload();
header("Location:index.php");
Exemple #15
0
 function m_uploadImage()
 {
     $fileUpload = new FileUpload();
     if ($this->request['type'] == "menu") {
         $this->obDb->query = "SELECT vImage from " . MENUITEMS . " WHERE iMenuItemsId=" . $this->request['id'];
         $rsImage = $this->obDb->fetchQuery();
     } else {
         $this->obDb->query = "SELECT vImage from " . MENUHEADERS . " WHERE iHeaderid_PK=" . $this->request['id'];
         $rsImage = $this->obDb->fetchQuery();
     }
     if ($this->libFunc->checkImageUpload("image")) {
         $fileUpload->source = $_FILES["image"]["tmp_name"];
         $fileUpload->target = $this->imagePath . "menu/" . $_FILES["image"]["name"];
         $newName1 = $fileUpload->upload();
         if ($newName1 != false) {
             $image = $newName1;
         }
         if (!empty($rsImage[0]->vImage)) {
             $fileUpload->deleteFile($this->imagePath . "menu/" . $rsImage[0]->vImage);
         }
         $imagename = "image";
     } else {
         $image = $rsImage[0]->vImage;
     }
     if ($this->request['type'] == "menu") {
         $this->obDb->query = "UPDATE " . MENUITEMS . " SET `vImage`='{$image}' ,`tmEditDate`='" . time() . "', `iAdminUser` ='" . $_SESSION['uid'] . "'  WHERE iMenuItemsId  ='" . $this->request['id'] . "'";
     } else {
         $this->obDb->query = "UPDATE " . MENUHEADERS . " SET `vImage`='{$image}',`tmEditDate`='" . time() . "', `iAdminUser` ='" . $_SESSION['uid'] . "' WHERE iHeaderid_PK ='" . $this->request['id'] . "'";
     }
     $this->obDb->updateQuery();
     $this->libFunc->m_mosRedirect(SITE_URL . "ecom/adminindex.php?action=ec_menu.uploadForm&status=1&id=" . $this->request['id'] . "&type=" . $this->request['type']);
 }
 function upload($path = '')
 {
     $path = trim($path, '/');
     $folder = $this->BasePath . $path;
     if (!is_dir($folder)) {
         if (is_gb2312($path)) {
             $path = iconv('gb2312', 'utf-8', $path);
         }
         throw new Exception("文件夹 '{$path}' 不存在。");
     }
     if (!file_exists('fileupload.class.php')) {
         throw new Exception("没找到文件'fileupload.class.php, 无法上传文件。");
     }
     require_once 'fileupload.class.php';
     $up = new FileUpload();
     //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
     $up->set("path", $folder);
     $up->set("maxsize", 8 * 1024 * 1024);
     if (empty($this->allowType) || $this->allowType == '*') {
         $up->set("allowtype", explode(',', $this->allType));
     } else {
         $up->set("allowtype", explode(',', $this->allowType));
     }
     $up->set("israndname", false);
     if (!$up->upload("file")) {
         $errors = $up->getErrorMsg();
         if (is_array($errors)) {
             $errors = implode("\n", $errors);
         }
         throw new Exception($errors);
     } else {
         $filenames = $up->getFileName();
         if (is_string($filenames)) {
             $filenames[] = $filenames;
         }
         foreach ($filenames as $key => $value) {
             $filename = iconv('utf-8', 'gb2312', $value);
             if (true === @rename($folder . '/' . $value, $folder . '/' . $filename)) {
                 $filenames[$key] = $filename;
             }
         }
     }
     return $up->getFileName();
 }
 function m_uploadFile()
 {
     $fileUpload = new FileUpload();
     $libFunc = new c_libFunctions();
     if (!isset($this->request['dir']) || empty($this->request['dir'])) {
         $this->libFunc->m_mosRedirect(SITE_URL . "admin/adminindex.php?action=file.home&msg=1");
         exit;
     }
     $this->defaultValues();
     $directory = $this->request['dir'];
     if ($this->libFunc->checkImageUpload("thisfile")) {
         //chmod($this->imagePath.$directory,0644);
         $fileUpload->source = $_FILES["thisfile"]["tmp_name"];
         $fileUpload->target = $this->imagePath . $directory . "/" . $_FILES["thisfile"]["name"];
         $newName1 = $fileUpload->upload();
     } else {
         $this->libFunc->m_mosRedirect(SITE_URL . "admin/adminindex.php?action=file.list&msg=4&dir=" . $directory);
     }
     $this->libFunc->m_mosRedirect(SITE_URL . "admin/adminindex.php?action=file.list&msg=3&dir=" . $directory);
 }
 static function uploadMulti($param, $destino, $nombre)
 {
     $result = array();
     if (isset($param['name'][0])) {
         $cambioArray = self::cambiarArray($param);
         for ($i = 0; $i < count($cambioArray); $i++) {
             $sube = new FileUpload($cambioArray[$i]);
             $sube->setDestino($destino);
             $sube->setNombre($nombre);
             $sube->setPolitica(FileUpload::REEMPLAZAR);
             $sube->upload();
             $error_subida = array($sube->getErrorCode(), $sube->getErrorMessage());
             array_push($result, $error_subida);
         }
         return $result;
     } else {
         $sube = new FileUpload($param);
         $sube->setDestino($destino);
         $sube->setNombre($nombre);
         $sube->setPolitica(FileUpload::REEMPLAZAR);
         $sube->upload();
         $error_subida = array($sube->getErrorCode(), $sube->getErrorMessage());
         array_push($result, $error_subida);
     }
     return result;
 }
Exemple #19
0
function createFile($title, $type, $content)
{
    //生成文件
    $File = new FileUtil();
    $File->writetofile(BASE_PATH . 'upload/webstyle/public/' . $type . '/' . $title . '.' . $type, $content);
    return $codeFilePath = '/manage/upload/webstyle/public/' . $type . '/' . $title . '.' . $type;
}
if (isset($_POST['category']) && $_POST['category'] == 'code') {
    $up = new FileUpload();
    //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
    $up->set("path", "../../upload/webstyle/public/" . $_POST['code_type']);
    $up->set("maxsize", 2000000);
    $up->set("allowtype", array("gif", "png", "jpg", "jpeg", 'css', 'js'));
    $up->set("israndname", false);
    //使用对象中的upload方法, 就可以上传文件, 方法需要传一个上传表单的名子 pic, 如果成功返回true, 失败返回false
    if ($up->upload("file")) {
        var_dump($up->getFileName());
        $file_path_code = '/manage/upload/webstyle/public/' . $_POST['code_type'] . '/' . $up->getFileName();
    } else {
        echo '<pre>';
        //获取上传失败以后的错误提示
        var_dump($up->getErrorMsg());
        echo '</pre>';
    }
    $db = new DB();
    $data['id'] = "";
    $data['title'] = $_POST['code_title'];
    //$data['content'] = $_POST['code_content'];
    $data['type'] = $_POST['code_type'];
    $data['file_path'] = $file_path_code;
    $data['is_public'] = 1;
$userManager = new ManageUser($db);
$sesion = new Session();
$email = Request::post("email");
$newemail = Request::post("newemail");
$pass = Request::post("pass");
$alive = Request::post("alive");
$worker = Request::post("worker");
$admin = Request::post("admin");
$newemail = $newemail === null ? $email : $newemail;
$alive = $alive === null ? 0 : 1;
$worker = $worker === null ? 0 : 1;
$admin = $admin === null ? 0 : 1;
$usuario = $userManager->get($email);
$usuario->setEmail($newemail);
$usuario->setAlias(explode("@", $newemail)[0]);
$usuario->setAlive($alive);
$usuario->setWorker($worker);
$usuario->setAdmin($admin);
if ($pass !== null) {
    $usuario->setPass($pass);
}
$photo = new FileUpload("image");
if ($photo->getError() === false) {
    $usuario->setImage("images/" . $usuario->getAlias() . ".jpg");
    $photo->setDestination("../images/");
    $photo->setName($usuario->getAlias());
    echo $photo->upload();
}
$userManager->setEmail($usuario, $email);
$sesion->destroy();
$sesion->sendRedirect("../admin.php");
 function m_uploadCsv()
 {
     $this->errMsg = "";
     $requiredArray = array("vTitle", "vSeoTitle", "vSku", "fPrice");
     foreach ($requiredArray as $a) {
         if (!in_array($a, $this->request['item'])) {
             $this->err = 1;
             $this->errMsg = MSG_CSV_REQUIRED . "<br />";
         }
     }
     $ext = substr($_FILES['import_file']['name'], -3);
     if ($ext != "csv") {
         $this->err = 1;
         $this->errMsg .= MSG_INVALID_CSV;
     }
     if ($_FILES["import_file"]["size"] == 0) {
         $this->err = 1;
         $this->errMsg .= MSG_INVALID_CSV;
     }
     if ($this->err == 1) {
         $this->csvTemplate = $this->templatePath . "csvImporter.tpl.htm";
         $this->obTpl->set_var("TPL_VAR_BODY", $this->m_uploadFormCsv());
         return false;
     }
     $fileUpload = new FileUpload();
     $libFunc = new c_libFunctions();
     if ($this->libFunc->checkFileUpload("import_file")) {
         $fileUpload->source = $_FILES["import_file"]["tmp_name"];
         $fileUpload->target = $this->imagePath . $_FILES["import_file"]["name"];
         $newName = $fileUpload->upload();
     } else {
         $this->libFunc->m_mosRedirect(SITE_URL . "admin/adminindex.php?action=csv.home&msg=1");
         exit;
     }
     $this->csvImporter($this->imagePath . $newName);
 }
<?php

//texto y archivo
require '../clases/Request.php';
require '../clases/FileUpload.php';
$texto = Request::post("texto");
$peso = 999999;
echo "<h1>{$texto}</h1>";
//echo FileUpload::getErrorMessage().'<br/ >';
//echo FileUpload::getFileName().'<br/ >';
//echo FileUpload::getFileSize().'<br/ >';
echo FileUpload::getFileTipe() . '<br/ >';
//echo FileUpload::getTmpName().'<br/ >';
FileUpload::upload($texto);
echo FileUpload::maxFileSize($peso) . '<br/ >';
//move_uploaded_file($_FILES["archivo"]["tmp_name"],"./X");
<?php

require '../clases/AutoCarga.php';
$bd = new DataBase();
$gestor = new ManageGame($bd);
$juego = new Game();
$juego->read();
$subir = new FileUpload("caratula");
$subir->setDestino("./caratulas/");
$subir->setTamaño(100000000);
$subir->setNombre($subir->getNombre());
$subir->setPolitica(FileUpload::REEMPLAZAR);
if ($subir->upload()) {
    echo 'Archivo subido con éxito';
} else {
    echo 'Archivo no subido';
}
$juego->setCaratula($subir->getNombre());
$pkID = Request::post("pkID");
$r = $gestor->set($juego, $pkID);
$bd->close();
//echo $r;
//var_dump($bd->getError());
header("Location:index.php?op=edit&r={$r}");
Exemple #24
0
 function m_uploadImage()
 {
     $fileUpload = new FileUpload();
     if ($this->request['type'] == "product") {
         $this->obDb->query = "SELECT iProdid_PK,vTitle,vImage1,vImage2,vImage3,tImages,vDownloadablefile ";
         $this->obDb->query .= " FROM " . PRODUCTS . " where iProdid_PK ='" . $this->request['id'] . "'";
         $this->imagePath = $this->imagePath . "product/";
     } elseif ($this->request['type'] == "content") {
         $this->obDb->query = "SELECT iContentId_PK,vTitle,vImage1,vImage2,vImage3 FROM " . CONTENTS;
         $this->obDb->query .= " WHERE iContentId_PK ='" . $this->request['id'] . "'";
         $this->imagePath = $this->imagePath . "content/";
     } else {
         $this->obDb->query = "SELECT iDeptId_PK,vTitle,vImage1,vImage2,vImage3 FROM " . DEPARTMENTS;
         $this->obDb->query .= " WHERE iDeptId_PK ='" . $this->request['id'] . "'";
         $this->imagePath = $this->imagePath . "department/";
     }
     $rsImage = $this->obDb->fetchQuery();
     if ($this->libFunc->checkImageUpload("image1")) {
         if (is_file($this->imagePath . $rsImage[0]->vImage1)) {
             $fileUpload->deleteFile($this->imagePath . $rsImage[0]->vImage1);
         }
         $fileUpload->source = $_FILES["image1"]["tmp_name"];
         $fileUpload->target = $this->imagePath . $_FILES["image1"]["name"];
         $newName1 = $fileUpload->upload();
         if ($newName1 != false) {
             $image1 = $newName1;
             //
             if ($this->libFunc->ifSet($this->request, "resample")) {
                 // This section is used by product, dept and content:
                 switch ($this->request['type']) {
                     case "product":
                         $fileUpload->resampleImage($this->imagePath . $newName1, UPLOAD_SMIMAGEWIDTH, UPLOAD_SMIMAGEHEIGHT, UPLOAD_JPGCOMPRESSION);
                         break;
                     case "dept":
                         $fileUpload->resampleImage($this->imagePath . $newName1, UPLOAD_DEPTSMIMAGEWIDTH, UPLOAD_DEPTSMIMAGEHEIGHT, UPLOAD_JPGCOMPRESSION);
                         break;
                     case "content":
                         $fileUpload->resampleImage($this->imagePath . $newName1, UPLOAD_CONTENTSMIMAGEWIDTH, UPLOAD_CONTENTSMIMAGEHEIGHT, UPLOAD_JPGCOMPRESSION);
                         break;
                 }
             }
             // [/DRK]
         }
         $imagename = "image1";
     } else {
         $image1 = $rsImage[0]->vImage1;
         $imagename = $this->request['current_image'];
     }
     if ($this->libFunc->checkImageUpload("image2")) {
         if (is_file($this->imagePath . $rsImage[0]->vImage2)) {
             $fileUpload->deleteFile($this->imagePath . $rsImage[0]->vImage2);
         }
         $fileUpload->source = $_FILES["image2"]["tmp_name"];
         $fileUpload->target = $this->imagePath . $_FILES["image2"]["name"];
         $newName2 = $fileUpload->upload();
         if ($newName2 != false) {
             $image2 = $newName2;
             //
             if ($this->libFunc->ifSet($this->request, "resample")) {
                 // This section is used by product and dept:
                 switch ($this->request['type']) {
                     case "product":
                         $fileUpload->resampleImage($this->imagePath . $newName2, UPLOAD_MDIMAGEWIDTH, UPLOAD_MDIMAGEHEIGHT, UPLOAD_JPGCOMPRESSION);
                         break;
                     case "dept":
                         $fileUpload->resampleImage($this->imagePath . $newName2, UPLOAD_DEPTMDIMAGEWIDTH, UPLOAD_DEPTMDIMAGEHEIGHT, UPLOAD_JPGCOMPRESSION);
                         break;
                 }
             }
             // [/DRK]
         }
         $imagename = "image2";
     } else {
         $image2 = $rsImage[0]->vImage2;
         $imagename = $this->request['current_image'];
     }
     if ($this->libFunc->checkImageUpload("image3")) {
         if (is_file($this->imagePath . $rsImage[0]->vImage3)) {
             $fileUpload->deleteFile($this->imagePath . $rsImage[0]->vImage3);
         }
         $fileUpload->source = $_FILES["image3"]["tmp_name"];
         $fileUpload->target = $this->imagePath . $_FILES["image3"]["name"];
         $newName3 = $fileUpload->upload();
         if ($newName3 != false) {
             $image3 = $newName3;
             if ($this->libFunc->ifSet($this->request, "resample")) {
                 $fileUpload->resampleImage($this->imagePath . $newName3, UPLOAD_LGIMAGEWIDTH, UPLOAD_LGIMAGEHEIGHT, UPLOAD_JPGCOMPRESSION);
             }
         }
         $imagename = "image3";
     } else {
         $image3 = $rsImage[0]->vImage3;
         $imagename = $this->request['current_image'];
     }
     if ($this->request['type'] == "product") {
         if ($this->libFunc->checkFileUpload("image4")) {
             if (is_file($this->imagePath . "../files/" . $rsImage[0]->vDownloadablefile)) {
                 $fileUpload->deleteFile($this->imagePath . "../files/" . $rsImage[0]->vDownloadablefile);
             }
             $fileUpload->source = $_FILES["image4"]["tmp_name"];
             $fileUpload->target = $this->imagePath . "../files/" . $_FILES["image4"]["name"];
             $newName4 = $fileUpload->upload();
             if ($newName4 != false) {
                 $image4 = $newName4;
             }
             $imagename = "image4";
         } else {
             $image4 = $rsImage[0]->vDownloadablefile;
             $imagename = $this->request['current_image'];
         }
     }
     if ($this->request['type'] == "product") {
         $extraimages = explode(",", $rsImage[0]->tImages);
         $countExtraImage = count($extraimages);
         if (substr($this->request['current_image'], 0, -1) == 'extraimage') {
             $j = substr($this->request['current_image'], -1);
             $t = $j - 1;
             if ($this->libFunc->checkImageUpload("extraimage" . $j)) {
                 if (is_file($this->imagePath . $extraimages[$t])) {
                     $fileUpload->deleteFile($this->imagePath . $extraimages[$t]);
                 }
                 $fileUpload->source = $_FILES["extraimage" . $j]["tmp_name"];
                 $fileUpload->target = $this->imagePath . $_FILES["extraimage" . $j]["name"];
                 $newName[$j] = $fileUpload->upload();
                 if ($newName[$j] != false) {
                     $image[$j] = $newName[$j];
                 }
                 $imagename = "extraimage" . $j;
             } else {
                 $image[$j] = $extraimages[$t];
                 $imagename = $this->request['current_image'];
             }
             $extraimages[$t] = $image[$j];
         }
         $imageString = "";
         for ($i = 0; $i < 6; $i++) {
             $imageString .= $extraimages[$i] . ",";
         }
     }
     //----
     if ($this->request['type'] == "product") {
         $this->obDb->query = "UPDATE " . PRODUCTS . " SET \n\t\t\t\t\t\t `vImage1`='{$image1}', `vImage2`='{$image2}', `vImage3`='{$image3}',`tImages`= '" . $imageString . "', vDownloadablefile='{$image4}',\n\t\t\t\t\t\t `tmEditDate`='" . time() . "', `iAdminUser` ='" . $_SESSION['uid'] . "'  where iProdId_PK = " . $this->request['id'];
     } elseif ($this->request['type'] == "content") {
         $this->obDb->query = "UPDATE " . CONTENTS . " SET \n\t\t\t\t\t\t `vImage1`='{$image1}', `vImage2`='{$image2}', `vImage3`='{$image3}',\n\t\t\t\t\t\t `tmEditDate`='" . time() . "', `vAdminUser` ='" . $_SESSION['uid'] . "'  where iContentId_PK = " . $this->request['id'];
     } else {
         $this->obDb->query = "UPDATE " . DEPARTMENTS . " SET \n\t\t\t\t\t\t `vImage1`='{$image1}', `vImage2`='{$image2}', `vImage3`='{$image3}',\n\t\t\t\t\t\t `tmEditDate`='" . time() . "', `vAdminUser` ='" . $_SESSION['uid'] . "'  where iDeptId_PK = " . $this->request['id'];
     }
     $this->obDb->updateQuery();
     if (!isset($imagename)) {
         $imagename = 'image1';
     }
     $str = SITE_URL . "ecom/adminindex.php?action=ec_show.dspUploadFrm&status=1&image={$imagename}&id=" . $this->request['id'] . "&type=" . $this->request['type'];
     $this->libFunc->m_mosRedirect($str);
 }
 function modificarObra()
 {
     $n = Request::post('nombre');
     $t = Request::post('tecnica');
     $i = Request::post('id_obra');
     $obra = $this->gestorObra->get($i);
     $lista = $this->gestorObra->getListObrasEmail($this->sesion->get("usu"));
     $formusuario = $this->plantilla->get('_formusuario');
     $formsesion = $this->plantilla->get('_formsesion');
     $obra->setNombre($n);
     $obra->setTecnica($t);
     $this->gestorObra->set($obra);
     $this->sesion->destroy();
     $fileUpload = new FileUpload($_FILES["imagen"]);
     $fileUpload->setNombre($n);
     $fileUpload->setDestino("imagenes/obras/");
     $fileUpload->upload();
     $usuario = $this->gestorUsu->get($this->sesion->get("usu"));
     $paginaDos = $this->plantilla->get('_formmod');
     $campos = "";
     $d = array("email" => $usuario->getEmail(), "clave" => $usuario->getClave(), "alias" => $usuario->getAlias());
     $pDos = $this->plantilla->replace($d, $paginaDos);
     $pagina = $this->plantilla->get('_usuario');
     $datos = array("registro" => "", "nombresesion" => $this->sesion->get("usu"), "formsesion" => $formsesion, "datos" => $formusuario, "formmod" => $pDos, "login" => "", "mensaje" => "", "mensajesubida" => "", "mensajemod" => "", "contenidoobras" => "", "modificaobra" => "", "mensajemodobra" => "Operación realizada correctamente.");
     $p = $this->plantilla->replace($datos, $pagina);
     echo $p;
 }
 function m_uploadImage()
 {
     $fileUpload = new FileUpload();
     $name = $this->request['img'];
     if ($this->libFunc->checkImageUpload("image")) {
         $fileUpload->source = $_FILES["image"]["tmp_name"];
         $fileUpload->target = $this->imagePath . "giftwrap/" . $_FILES["image"]["name"];
         $newName1 = $fileUpload->upload();
         $this->obDb->query = "UPDATE " . GIFTWRAPS . " set\n\t\t\t\t {$name}='{$newName1}' where iGiftwrapid_PK='" . $this->request['id'] . "'";
         $this->obDb->updateQuery();
     } else {
         $this->libFunc->m_mosRedirect(SITE_URL . "sales/adminindex.php?action=promotions.giftwrap.uploadForm&msg=2&img=" . $this->request['img'] . "&id=" . $this->request['id']);
     }
     $this->libFunc->m_mosRedirect(SITE_URL . "sales/adminindex.php?action=promotions.giftwrap.uploadForm&msg=1&img=" . $this->request['img'] . "&id=" . $this->request['id']);
 }