コード例 #1
0
ファイル: function.upload.php プロジェクト: nubix/cms
/**
 * Author : Jan Germann
 * Datum : 26.04.2010
 * Modul : files
 * Beschreibung : Dateien Hochladen in UPLOAD_DIR
*/
function upload()
{
    global $msg, $mysql, $log;
    if (!isset($_POST['submit'])) {
        $tpl = dirname(__FILE__) . "/template/upload.form.tpl";
        if (is_file($tpl)) {
            $template = file_get_contents($tpl);
        }
        $template = str_replace("%name%", $_POST['name'], $template);
        $template = str_replace("%description%", $_POST['description'], $template);
        return $data = $template;
    } else {
        if ($_FILES['file']['error'] == 4) {
            $msg->error("Es wurde keine Datei hochgeladen.");
        }
        if (empty($_POST['name'])) {
            $msg->error("Es wurde kein Name angegeben.");
        }
        if ($msg->error) {
            unset($_POST['submit']);
            return upload();
        } else {
            $safe_filename = preg_replace(array("/\\s+/", "/[^-\\.\\w]+/"), array("_", ""), trim($_FILES['file']['name']));
            if (is_uploaded_file($_FILES['file']['tmp_name']) && !@move_uploaded_file($_FILES['file']['tmp_name'], UPLOAD_DIR . $safe_filename)) {
                $msg->error("Fehler beim Dateiupload.");
                unset($_POST['submit']);
                return upload();
            }
            $mysql->insert("files", array(NULL, mysql_real_escape_string($_POST['name']), mysql_real_escape_string($_POST['description']), $safe_filename));
            $msg->success("Upload erfolgreich.");
            $log->add("Dateiupload", "<file>" . $safe_filename . "</file><name>" . mysql_real_escape_string($_POST['name']) . "</name><description>" . mysql_real_escape_string($_POST['description']) . "</description>");
        }
    }
}
コード例 #2
0
ファイル: funk.php プロジェクト: TaaviTilk/i244_kodutood
function lisa()
{
    // siia on vaja funktsionaalsust (13. nädalal)
    if (!empty($_SESSION["user"])) {
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            // postitus on tehtud
            if (in_array("", $_POST) || $_FILES["pilt"]["error"] > 0) {
                $errors[] = "Mingi väli jäi postitamisel tühjaks või on faili üleslaadimisel tekkinud viga.";
                include_once 'views/loomavorm.html';
            } else {
                // kõik ok, laeme faili üles ja teeme kirje tabelisse
                connect_db();
                upload("pilt");
                $query = "INSERT INTO ttilk__loomaaed (NIMI, PUUR, PILT) \n\t\t\t\t\t\t\tVALUES ('" . mysqli_real_escape_string($GLOBALS['connection'], $_POST["nimi"]) . "', '" . mysqli_real_escape_string($GLOBALS['connection'], $_POST["puur"]) . "', '" . "pildid/" . $_FILES["pilt"]["name"] . "');";
                $result = mysqli_query($GLOBALS['connection'], $query) or die("{$query} - " . mysqli_error($GLOBALS['connection']));
                echo $_FILES["pilt"]["name"];
                //header("refresh:3; url=loomaaed.php?page=loomad");
            }
            // if
        } else {
            include_once 'views/loomavorm.html';
        }
        // if $_SERVER
    } else {
        header("Location: loomaaed.php?page=login");
    }
    // if !empty
}
コード例 #3
0
ファイル: UserCtrl.class.php プロジェクト: Jnnock/myyyk
 public function pic()
 {
     if (isset($_FILES['headpic']['name']) && strlen($_FILES['headpic']['name']) > 0) {
         $arr = array('upload' => 'headpic', 'ext' => array('jpg', 'jpeg', 'png', 'gif'), 'size' => 10240, 'path' => './asset/upload/');
         $file = upload($arr);
         if ($file['result']) {
             $user = new UserModel();
             $picName = $file['message'];
             $rst = $user->setPics($picName);
             if ($rst) {
                 R('User', 'ePic');
                 //$newUrl = U('User','ePic');
                 //echo "<script>window.location='http://localhost/YYK/msg/User/ePic.html'</script>";
             } else {
                 //E($this->errors['054']);
                 var_dump($rst);
                 echo "Wrong!~";
             }
         } else {
             //E($file['message']);
             echo "Wrong";
         }
     } else {
         var_dump($_FILES);
     }
 }
コード例 #4
0
ファイル: funk.php プロジェクト: kleemets/Vorgurakendused
function lisa()
{
    global $connection;
    if (empty($_SESSION["user"])) {
        header("Location: ?page=login");
    } else {
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            if ($_POST["nimi"] == '' || $_POST["puur"] == '') {
                $errors = array();
                if (empty($_POST["nimi"])) {
                    $errors[] = "Palun sisesta nimi!";
                }
                if (empty($_POST["puur"])) {
                    $errors[] = "Palun sisesta puur!";
                }
            } else {
                upload('liik');
                $nimi = mysqli_real_escape_string($connection, $_POST["nimi"]);
                $puur = mysqli_real_escape_string($connection, $_POST["puur"]);
                $liik = mysqli_real_escape_string($connection, "pildid/" . $_FILES["liik"]["name"]);
                $sql = "INSERT INTO kleemets_loomaaed (nimi, PUUR, liik) VALUES ('{$nimi}','{$puur}','{$liik}')";
                $result = mysqli_query($connection, $sql);
                $id = mysqli_insert_id($connection);
                if ($id) {
                    header("Location: ?page=loomad");
                } else {
                    header("Location: ?page=loomavorm");
                }
            }
        }
    }
    include_once 'views/loomavorm.html';
}
コード例 #5
0
ファイル: uploadFile.php プロジェクト: shesai0519/sunshineCRM
function uploadFile()
{
    global $_POST;
    global $_FILES;
    global $ATTACHMENT_ID_OLD;
    global $ATTACHMENT_NAME_OLD;
    if ($_POST['通达格式上传文件'] != "") {
        if (count($_FILES) > 1) {
            $ATTACHMENTS = upload();
            $CONTENT = ReplaceImageSrc($CONTENT, $ATTACHMENTS);
            $ATTACHMENT_ID = $ATTACHMENT_ID_OLD . $ATTACHMENTS["ID"];
            $ATTACHMENT_NAME = $ATTACHMENT_NAME_OLD . $ATTACHMENTS["NAME"];
        } else {
            $ATTACHMENT_ID = $ATTACHMENT_ID_OLD;
            $ATTACHMENT_NAME = $ATTACHMENT_NAME_OLD;
        }
        $ATTACHMENT_ID .= copy_sel_attach($ATTACH_NAME, $ATTACH_DIR, $DISK_ID);
        $ATTACHMENT_NAME .= $ATTACH_NAME;
        $上传附件字段名称 = $_POST['通达格式上传文件'];
        //对附件上传字段重新赋值
        $_POST[$上传附件字段名称] = $ATTACHMENT_NAME . "||" . $ATTACHMENT_ID;
        //print_R($_POST);print_R($_FILES);print_R($ATTACHMENT_NAME);print_R($ATTACHMENT_ID);exit;
    }
    //通达格式上传文件处理结束
}
コード例 #6
0
ファイル: kexport.php プロジェクト: kaantunc/MYK-BOR
function saveKimport($option)
{
    if (isset($_FILES['uploadfile']) && is_array($_FILES['uploadfile'])) {
        $file = $_FILES['uploadfile'];
        upload($option, $file, '');
    }
}
コード例 #7
0
ファイル: funk.php プロジェクト: aveinber/Ylesanded
function lisa()
{
    // siia on vaja funktsionaalsust (13. nädalal)
    $errors = array();
    if (!empty($_SESSION['username'])) {
        include_once 'views/login.html';
    } else {
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            if (in_array("", $_POST)) {
                $errors[] = "Väljad täita!";
                include_once 'views/loomavorm.html';
            } else {
                global $connection;
                upload('liik');
                $nimi = mysqli_real_escape_string($connection, $_POST['nimi']);
                $puur = mysqli_real_escape_string($connection, $_POST['puur']);
                $liik = mysqli_real_escape_string($connection, "pildid/" . $_FILES["liik"]["name"]);
                $query = "INSERT INTO aveinber_loomaaed (nimi, puur, liik ) values ('{$nimi}','{$puur}','{$liik}')";
                $result = mysqli_query($connection, $query) or die("Ei saanud päringut teha " . mysqli_error($connection));
                header('Location:loomaaed.php?page=loomad');
            }
        } else {
            include_once 'views/loomavorm.html';
        }
    }
}
コード例 #8
0
/**
 * Functions registered with the worker
 *
 * @param object $job 
 * @return void
 */
function internal_upload($job)
{
    //Get the info of the job
    list($localFilename, $remoteFilename, $removeFile) = unserialize($job->workload());
    //Default value if empty
    if (is_null($removeFile)) {
        $removeFile = FALSE;
    }
    //Do some checks
    if (empty($localFilename) || empty($remoteFilename)) {
        logError(sprintf("%s: The workload do not contain the required info to do the upload\n\n", date('r')));
        $job->sendFail();
        return FALSE;
    }
    echo sprintf("%s: Received job to internal upload %s\n", date('r'), $localFilename);
    //Do the upload
    $uploaded = upload($localFilename, $remoteFilename);
    if ($uploaded !== TRUE) {
        logError(sprintf("%s: Error while uploading the file to Amazon S3 - %s\n\n", date('r'), $uploaded->getMessage()));
        $job->sendFail();
        return FALSE;
    }
    //Check if we have to remove the file
    if ($removeFile) {
        //Remove the original file
        if (!unlink(ROOT_PATH . '/public/frontend/tmp/' . $localFilename)) {
            logError(sprintf("%s: Error removing the file\n\n", date('r')));
            $job->sendFail();
            return FALSE;
        }
    }
    $job->sendComplete(TRUE);
    echo sprintf("%s: Job finished successfully\n\n", date('r'));
    return TRUE;
}
コード例 #9
0
ファイル: funk.php プロジェクト: rturi/I244
function lisa()
{
    // siia on vaja funktsionaalsust (13. nädalal)
    global $connection;
    if (isset($_SESSION['user_role']) && $_SESSION['user_role'] == "admin") {
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $upload_field_name = 'liik';
            if (empty($_POST['nimi'])) {
                $errors['empty_name'] = "Sisesta nimi";
            }
            if (empty($_POST['puur'])) {
                $errors['empty_cage'] = "Sisesta puur";
            }
            //if(empty($_POST['liik'])) $errors['empty_species'] = "Sisesta liik";
            if (upload($upload_field_name) == "") {
                $errors['upload_failed'] = "Faili upload ebaõnnestus";
            }
            $speciesFromImageName = explode(".", $_FILES[$upload_field_name]["name"]);
            $insertName = mysqli_real_escape_string($connection, htmlspecialchars($_POST['nimi']));
            $insertCage = mysqli_real_escape_string($connection, htmlspecialchars($_POST['puur']));
            $insertSpecies = mysqli_real_escape_string($connection, htmlspecialchars($speciesFromImageName[0]));
            $sql = "INSERT INTO `rturi_zoo`(`name`, `species`, `cage`) VALUES ('" . $insertName . "','" . $insertSpecies . "'," . $insertCage . ")";
            $result = mysqli_query($connection, $sql) or die("{$sql} - " . mysqli_error($connection));
            echo mysqli_insert_id($connection);
            if (mysqli_insert_id($connection) > 0) {
                header("Location: ?page=loomad");
                exit(0);
            }
        }
    } else {
        header("Location: ?");
        exit(0);
    }
    include_once 'views/loomavorm.html';
}
コード例 #10
0
ファイル: Student.php プロジェクト: idoqo/yedoe
 public function uploadResume($file, $pdfPath, $thumbPath)
 {
     $types = array("application/pdf", "application/x-pdf", "text/pdf", "application/acrobat", "application/vnd.pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
     $pad = str_replace(" ", "_", $this->fullName);
     $attempt = upload($pdfPath, $file, $pad, $types);
     if (!is_array($attempt)) {
         return $attempt;
     }
     if (!array_key_exists("main_name", $attempt) || !array_key_exists("new_name", $attempt)) {
         return $attempt;
     }
     $newName = $attempt['new_name'];
     $conn = new PDO(DB_DSN, DB_USER, DB_PASS);
     $sql = "INSERT INTO seekers(userID, cv_file) VALUES(:id, :file)";
     if ($this->getResumeFile()) {
         $sql = "UPDATE seekers SET cv_file = :file WHERE userID = :id";
     }
     $st = $conn->prepare($sql);
     $st->bindParam(":id", $this->userID);
     $st->bindParam(":file", $newName);
     try {
         if (!$st->execute()) {
             unlink($pdfPath . $newName);
             return $st->errorInfo();
         } else {
             $mainFile = $pdfPath . $newName;
             $thumb = $newName . ".jpg";
             //execute ImageMagick's convert command
             //exec("covert \"{$mainFile[0]}\" -colorspace RGB -geometry 400 $thumbPath$thumb");
             return true;
         }
     } catch (PDOException $e) {
         return $e->getMessage();
     }
 }
コード例 #11
0
 public function upload()
 {
     $data = upload('./Wx/Material/');
     if (is_array($data)) {
         $path = 'http://' . $_SERVER['HTTP_HOST'] . ltrim($data['file']['file_save_path'], '.');
         $this->ajaxSuccess($path);
     }
     $this->ajaxError('上传失败' . $data);
 }
コード例 #12
0
ファイル: ajax.php プロジェクト: robkub/tc-tools
function doUpload()
{
    // Metadaten zu Banner angegeben?
    if (empty($_GET["tag"]) || empty($_GET["name"])) {
        die(json_encode(array("error" => "FORM VALIDATION: Kein Allianzname oder kein Allianztag angegeben.")));
    }
    // Datei hochgeladen?
    if (empty($_FILES[UPLOAD_BANNER_ID])) {
        die(json_encode(array("error" => "FORM VALIDATION: Keine Datei zum Hochladen ausgew&aauml;hlt.")));
    }
    // Fehler beim upload
    if (isset($_FILES[UPLOAD_BANNER_ID]['error']) && intval($_FILES[UPLOAD_BANNER_ID]['error']) > 0) {
        switch ($_FILES[UPLOAD_BANNER_ID]['error']) {
            case '1':
                $error = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
                break;
            case '2':
                $error = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
                break;
            case '3':
                $error = 'The uploaded file was only partially uploaded';
                break;
            case '4':
                $error = 'No file was uploaded.';
                break;
            case '6':
                $error = 'Missing a temporary folder';
                break;
            case '7':
                $error = 'Failed to write file to disk';
                break;
            case '8':
                $error = 'File upload stopped by extension';
                break;
            case '999':
            default:
                $error = 'No error code avaiable';
        }
        die(json_encode(array("error" => "UPLOAD ERROR: " . $error . ".")));
    }
    $tmp_filename = $_FILES[UPLOAD_BANNER_ID]['tmp_name'];
    $img_size = getimagesize($tmp_filename);
    // Datei ist Bild?
    if (!is_array($img_size)) {
        die(json_encode(array("error" => "UPLOAD ERROR: Die hochgeladene Datei ist kein Bild.")));
    }
    // Datei hat richtige Größe?
    if ($img_size[0] != BANNER_WIDTH || $img_size[1] != BANNER_HEIGHT) {
        die(json_encode(array("error" => "UPLOAD ERROR: Die hochgeladene Datei hat nicht die richtige Gr&ouml;&szlig;e. (Breite: " + BANNER_WIDTH + ", H&ouml;he: " + BANNER_HEIGHT + ")")));
    }
    // Allright, copy file and return info
    $id = upload($_FILES[UPLOAD_BANNER_ID], $_GET["tag"], $_GET["name"]);
    $banner = get_banner($id);
    echo '{"success": true, id: "' . $id . '", "filename": "' . rawurlencode($banner["url"]) . '", "path": "' . rawurlencode(BANNER_PATH . $banner["url"]) . '"}';
}
コード例 #13
0
ファイル: ArticlesEvent.class.php プロジェクト: xswolf/dc
 /**
  * 上传图片
  */
 public function uploadImg()
 {
     //'ybFlQ9kmPTgiCWZT8Mq_1YnKtBziwpbaVDaftpJckPtFzlwROlgXpKCd9Dbl_JRs'
     if (!empty($_FILES)) {
         $info = reset(upload());
         $data = Media::upload(realpath($info['file_save_path']), 'image');
         file_put_contents('./wx-test/uploadimg.txt', json_encode($data));
         dump($data);
     }
     //        dump(  Media::upload(realpath('./Public/Uploads/2015-09-23/560218d10525f.jpg'),'image' ));
 }
コード例 #14
0
ファイル: Message.php プロジェクト: idoqo/yedoe
 public function addAttachment($file, $path)
 {
     $allowed = array("image/jpeg", "image/jpg", "image/png", "image/gif", "application/pdf", "application/x-pdf", "text/pdf", "application/acrobat", "application/vnd.pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
     $pad = uniqid('msg_file_', true);
     $attempt = upload($path, $file, $pad, $allowed);
     if (!is_array($attempt)) {
         return $attempt;
     }
     if (!array_key_exists("main_name", $attempt) || !array_key_exists("new_name", $attempt)) {
         return $attempt;
     }
 }
コード例 #15
0
 public function processRequest()
 {
     if ($_SERVER["REQUEST_METHOD"] == "GET") {
         print "WebORB v3.5.0";
     }
     $timeStart = microtime(true);
     ob_start();
     $inputData = file_get_contents("php://input");
     if (isset($_FILES['Filedata'])) {
         $config = ORBConfig::getInstance();
         if (!defined("WebOrbServicesPath")) {
             define("WebOrbServicesPath", realpath(WebOrb . $config->getServicePath()) . DIRECTORY_SEPARATOR);
             if (LOGGING) {
                 Log::log(LoggingConstants::DEBUG, "WebORB services path is - " . WebOrbServicesPath);
             }
         }
         require_once WebOrbServicesPath . "Weborb/Examples/Upload.php";
         upload();
         exit;
     }
     $startRead = microtime(true);
     try {
         $config = ORBConfig::getInstance();
         if (!defined("WebOrbServicesPath")) {
             define("WebOrbServicesPath", realpath(WebOrb . $config->getServicePath()) . DIRECTORY_SEPARATOR);
             if (LOGGING) {
                 Log::log(LoggingConstants::DEBUG, "WebORB services path is - " . WebOrbServicesPath);
             }
         }
         $contentType = "text/html";
         if (stripos($_SERVER["CONTENT_TYPE"], "wolf/xml") !== false) {
             $contentType = "wolf/xml";
         } elseif (stripos($_SERVER["CONTENT_TYPE"], "application/x-amf") !== false) {
             $contentType = "application/x-amf";
         }
         $request = $config->getProtocolRegistry()->buildMessage($contentType, $inputData);
     } catch (Exception $e) {
         if (LOGGING) {
             Log::logException(LoggingConstants::ERROR, "Internal error", $e);
         }
         ob_clean();
         return;
     }
     if (DrupalDispatcher::dispatch($request)) {
         $this->serializeResponse($request);
     }
     $logMessage = sprintf("Final Execute time: %0.3f", microtime(true) - $timeStart);
     if (LOGGING) {
         Log::log(LoggingConstants::PERFORMANCE, $logMessage);
     }
 }
コード例 #16
0
 private function content($ref_id)
 {
     $ext = 'jpg,jpeg,gif,png';
     $files = isset($_FILES['filedata']) ? $_FILES['filedata'] : null;
     $attachment = upload($files, false, $ext, 'content', $error);
     if ($attachment != '') {
         $data = ['uploadfrom' => 'content', 'ref_id' => $ref_id, 'path' => $attachment];
         //Upload_Model::saveUpload($data);
         echo "{'err':'','msg':'" . $attachment . "'}";
         exit;
     }
     echo "{'err':'{$error}','msg':''}";
     exit;
 }
コード例 #17
0
 public function uploadx($name = '')
 {
     $name = trim($name);
     $uploadConfig = array($_FILES['photo'], 1024 * 1024 * 10, array('jpg', 'png', 'gif', 'jpeg'), C('PHOTOS_IMAGE_PATH'), false, $name);
     $uploadResult = upload($uploadConfig[0], $uploadConfig[1], $uploadConfig[2], $uploadConfig[3], $uploadConfig[4], $uploadConfig[5]);
     $uploadResult = (array) $uploadResult;
     if ($uploadResult['success']) {
         $newId = $this->_service->add($uploadResult['savename'], $uploadResult['filePath']);
         $uploadResult['newId'] = $newId;
         //生成ID
     }
     $this->assign('inst', $uploadResult);
     $this->display('result');
 }
コード例 #18
0
ファイル: functions.php プロジェクト: rturi/I244
function show_img_upload()
{
    global $connection;
    $thumb_upload = '';
    $img_upload = '';
    $input_title = '';
    $input_author = '';
    if (isset($_SESSION['username'])) {
        $errors = array();
        if (!empty($_POST)) {
            if (empty($_POST['title'])) {
                $errors['upload_empty_title'] = "Palun sisesta pildi nimi";
            } else {
                $input_title = htmlspecialchars($_POST['title']);
            }
            if (empty($_POST['author'])) {
                $errors['upload_empty_author'] = "Palun sisesta pildi autor";
            } else {
                $input_author = htmlspecialchars($_POST['author']);
            }
            $thumb_upload = upload('thumb', 'thumb');
            $img_upload = upload('img', 'img');
            if ($img_upload == "") {
                $errors['upload_img_failed'] = "Suure pildi upload ebaõnnestus";
            }
            if ($thumb_upload == "") {
                $errors['upload_thumb_failed'] = "Väikse pildi upload ebaõnnestus";
            }
            echo $thumb_upload;
            listFolderFiles('thumb/');
            if (!isset($errors['upload_empty_author']) && !isset($errors['upload_empty_title']) && !isset($errors['upload_img_failed']) && !isset($errors['upload_thumb_failed'])) {
                $sql = "INSERT INTO `rturi_pildid`(`thumb`, `pilt`, `pealkiri`, `autor`) VALUES ('thumb/" . mysqli_real_escape_string($connection, $thumb_upload) . "','img/" . mysqli_real_escape_string($connection, $img_upload) . "','" . mysqli_real_escape_string($connection, $input_title) . "','" . mysqli_real_escape_string($connection, $input_author) . "')";
                $result = mysqli_query($connection, $sql) or die("{$sql} - " . mysqli_error($connection));
                if (mysqli_insert_id($connection) > 0) {
                    $_SESSION['upload_success'] = 'Pildi upload õnnestus';
                    header("Location: ?mode=gallery");
                    exit(0);
                } else {
                    $errors['upload_db_insert_failed'] = "Pildi salvestamine ebaõnnestus. Sorry.";
                }
            }
        }
        include_once 'view/head.html';
        include 'view/img_upload.html';
        include_once 'view/foot.html';
    } else {
        header('Location: ?mode=main_page');
        exit(0);
    }
}
コード例 #19
0
ファイル: ViewManageShapes.php プロジェクト: rbarraud/nagvis
 private function uploadForm()
 {
     global $CORE;
     echo '<h2>' . l('Upload Shape') . '</h2>';
     if (is_action() && post('mode') == 'upload') {
         try {
             if (!isset($_FILES['image'])) {
                 throw new FieldInputError('image', l('You need to select an image to import.'));
             }
             $file = $_FILES['image'];
             if (!is_uploaded_file($file['tmp_name'])) {
                 throw new FieldInputError('image', l('The file could not be uploaded (Error: [ERROR]).', array('ERROR' => $file['error'] . ': ' . $CORE->getUploadErrorMsg($file['error']))));
             }
             $file_name = $file['name'];
             $file_path = path('sys', '', 'shapes') . $file_name;
             if (!preg_match(MATCH_PNG_GIF_JPG_FILE, $file_name)) {
                 throw new FieldInputError('image', l('The uploaded file is no image (png,jpg,gif) file or contains unwanted chars.'));
             }
             $data = getimagesize($file['tmp_name']);
             if (!in_array($data[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
                 throw new FieldInputError('image', l('The uploaded file is not an image ' . '(png, jpg and gif are allowed).'));
             }
             move_uploaded_file($file['tmp_name'], $file_path);
             $CORE->setPerms($file_path);
             success(l('The shape has been uploaded.'));
             //reload(null, 1);
         } catch (FieldInputError $e) {
             form_error($e->field, $e->msg);
         } catch (Exception $e) {
             if (isset($e->msg)) {
                 form_error(null, $e->msg);
             } else {
                 throw $e;
             }
         }
     }
     echo $this->error;
     js_form_start('upload_shape');
     hidden('mode', 'upload');
     echo '<input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="1000000" />';
     echo '<table class="mytable">';
     echo '<tr><td class="tdlabel">' . l('Choose an Image') . '</td>';
     echo '<td class="tdfield">';
     upload('image');
     echo '</td></tr>';
     echo '</table>';
     submit(l('Upload'));
     form_end();
 }
コード例 #20
0
 public function insert_base($web_base_info_m, $action, $web_name, $web_extension, $content, $type)
 {
     $file = $_FILES['logo'];
     $mes = upload($file);
     if (is_bool($mes)) {
         showMessage('图片上传失败!', "admin_csystem_mweb_base_info.html");
     }
     if (is_numeric($mes)) {
         showMessage('操作错误', 'admin_csystem_mweb_base_info.html');
     }
     if ($web_base_info_m->add($web_name, $web_extension, $content, $type, $mes)) {
         showMessage('网站信息添加成功!', "admin_csystem_mweb_base_info.html");
     } else {
         showMessage('网站信息添加失败!', "admin_csystem_mweb_base_info.html");
     }
 }
コード例 #21
0
ファイル: pics.action.php プロジェクト: lqlstudio/ttae_open
 function post()
 {
     global $_G;
     if (!$_G['pics_type']) {
         cpmsg('幻灯片分类不存在,请先添加', 'error', 'm=' . __CLASS__ . '&a=type_post');
     }
     if ($_GET['onsubmit'] && check()) {
         $pics = get_filed(__CLASS__, $_GET['postdb'], $_GET['id']);
         $url = '';
         if ($_FILES[file]) {
             $src = upload();
             if ($src) {
                 $pics[picurl] = $src;
             }
         }
         if ($_GET['id']) {
             $id = intval($_GET['id']);
             DB::update('pics', $pics, "id=" . $id);
             $url = '&id=' . $id;
             $msg = '修改';
             api_post(array('a' => 'update', 'table' => 'pics', 'data' => $pics, 'pre_key' => 'id', 'id' => $id, 'cache' => 'pics,pics_type'));
         } else {
             $msg = '添加';
             $pics['dateline'] = TIMESTAMP;
             $r = DB::insert('pics', $pics, true);
             if ($r > 0) {
                 api_post(array('a' => 'insert', 'table' => 'pics', 'data' => $pics, 'cache' => 'pics,pics_type', 'id' => $r));
             }
         }
         loadcache("pics_type", 'update');
         loadcache("pics", 'update');
         cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url);
         return false;
     } elseif ($_GET['id']) {
         $id = intval($_GET['id']);
         foreach ($_G['pics'] as $k => $v) {
             if (array_key_exists($id, $v)) {
                 $pics = $v[$id];
             }
         }
         $pics = dhtmlspecialchars($pics);
     } else {
         $pics = get_filed(__CLASS__);
     }
     $this->add(array('pics' => $pics));
     $this->show();
 }
コード例 #22
0
ファイル: JoinAction.class.php プロジェクト: baby-bus/babyweb
 public function save()
 {
     import('ORG.Util.FileToZip');
     $data = $_POST;
     $job = $data['job_select'];
     $job_class_id = intval($data["job_class_id"]);
     $job_id = intval($data["job_id"]);
     empty($_FILES['checkFile']['name']) && $this->error('简历限制最大为2M');
     empty($job) && $this->error('岗位必须选择');
     $data = upload($data, "./Public/Uploads/job_upload/", $this->_config);
     if ($data['error'] || empty($job_class_id) || empty($job_id)) {
         $this->error($data['error']);
     }
     $path_info = pathinfo($data[upload_url]);
     $file_name = $path_info["basename"];
     //文件名
     $save_path = "." . $path_info["dirname"] . "/";
     //保存路径
     if ($path_info["extension"] != "rar" && $path_info["extension"] != "zip") {
         $scandir = new traverseDir($save_path, $save_path);
         $file_path = $scandir->tozip(array($file_name));
         if ($file_path) {
             unlink("." . $data[upload_url]);
         } else {
             //$file_path=".".$data[upload_url];
             $this->error('提交失败');
         }
     } else {
         $file_path = $data["upload_url"];
     }
     $resume_db = M('resume', 'website_');
     $data["lang"] = LANG;
     $data["job_class_id"] = $job_class_id;
     $data["job_id"] = $job_id;
     $url = explode("index.php", $_SERVER["HTTP_REFERER"]);
     $data["file_path"] = $url[0] . ltrim($file_path, "./");
     $data["uploadtime"] = time();
     $subject = "【" . $job . "】岗位申请";
     $body = "【" . $job . "】岗位申请";
     if ($resume_db->add($data)) {
         $this->send($this->to, $subject, $body, $file_path);
         //unlink($file);
         $this->success('提交成功');
     } else {
         $this->error('提交失败');
     }
 }
コード例 #23
0
 /**
  * Update the specified resource in storage.
  *
  * @param  SponsorRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(SponsorRequest $request, $id)
 {
     try {
         $sponsor = Sponsor::findOrFail($id);
         $inputs = $request->all();
         if ($request->hasFile('image')) {
             $fileName = upload($request->file('image'), 'users', $sponsor->image);
             $inputs['image'] = $fileName;
         }
         $sponsor->fill($inputs)->save();
     } catch (ModelNotFoundException $ex) {
         Flash::error('No sponsor found' . $ex);
         return redirect()->route('sponsors.index');
     }
     Flash::success('Sponsor information updated successfully');
     return redirect()->route('sponsors.index');
 }
コード例 #24
0
 /**
  * Update the specified resource in storage.
  *
  * @param  ItemCategoryRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(ItemCategoryRequest $request, $id)
 {
     try {
         $category = ItemCategory::findOrFail($id);
         $inputs = $request->all();
         if ($request->hasFile('thumbnail')) {
             $fileName = upload($request->file('thumbnail'), 'items/categories', $category->thumbnail);
             $inputs['thumbnail'] = $fileName;
         }
         $category->fill($inputs)->save();
     } catch (ModelNotFoundException $ex) {
         Flash::error('No item category found' . $ex);
         return redirect()->route('store.categories.index');
     }
     Flash::success('Item category updated successfully');
     return redirect()->route('store.categories.index');
 }
コード例 #25
0
 /**
  * Update the specified resource in storage.
  *
  * @param  AmbassadorRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(AmbassadorRequest $request, $id)
 {
     try {
         $ambassador = Ambassador::findOrFail($id);
         $inputs = $request->all();
         if ($request->hasFile('image')) {
             $fileName = upload($request->file('image'), 'ambassadors', $ambassador->avatar);
             $inputs['avatar'] = $fileName;
         }
         $ambassador->fill($inputs)->save();
     } catch (ModelNotFoundException $ex) {
         Flash::error('No ambassador found' . $ex);
         return redirect()->route('ambassadors.index');
     }
     Flash::success('Ambassador information updated successfully');
     return redirect()->route('ambassadors.index');
 }
コード例 #26
0
ファイル: ad.action.php プロジェクト: lqlstudio/ttae_open
 function post()
 {
     global $_G;
     if ($_GET['onsubmit'] && check()) {
         $ad = get_filed(__CLASS__, $_GET['postdb'], $_GET['id']);
         $ad['start_time'] = dmktime($ad['start_time']);
         $ad['end_time'] = dmktime($ad['end_time']);
         $ad['width'] = intval($ad['width']);
         $ad['height'] = intval($ad['height']);
         $ad['hide'] = intval($ad['hide']);
         $ad['type'] = intval($ad['type']);
         $ad['target'] = intval($ad['target']);
         if ($_FILES[file]) {
             $pic = upload();
             if ($pic) {
                 $ad[picurl] = $pic;
             }
         }
         $url = '';
         if ($_GET['id']) {
             $id = intval($_GET['id']);
             DB::update(__CLASS__, $ad, "id=" . $id);
             $url = '&id=' . $id;
             $msg = '修改';
             api_post(array('a' => 'update', 'table' => 'ad', 'data' => $ad, 'pre_key' => 'id', 'id' => $id, 'cache' => 'ad'));
         } else {
             $msg = '添加';
             $ad['dateline'] = TIMESTAMP;
             $r = DB::insert(__CLASS__, $ad, true);
             if ($r > 0) {
                 api_post(array('a' => 'insert', 'table' => 'ad', 'data' => $ad, 'cache' => 'ad', 'id' => $r));
             }
         }
         loadcache(__CLASS__, 'update');
         cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url);
     } elseif ($_GET['id']) {
         $id = intval($_GET['id']);
         $ad = $_G['ad']['k' . $id];
     } else {
         $ad = get_filed(__CLASS__);
     }
     $ad_types = array(1 => '文字', 2 => '图片', 3 => 'HTML代码');
     $this->add(array('ad' => $ad, 'ad_types' => $ad_types));
     $this->show();
 }
コード例 #27
0
ファイル: photo.php プロジェクト: relisher/chyrp
 public function update($post)
 {
     if (!isset($_POST['filename'])) {
         if (isset($_FILES['photo']) and $_FILES['photo']['error'] == 0) {
             $this->delete_file($post);
             $filename = upload($_FILES['photo'], array("jpg", "jpeg", "png", "gif", "tiff", "bmp"));
         } elseif (!empty($_POST['from_url'])) {
             $this->delete_file($post);
             $filename = upload_from_url($_POST['from_url'], array("jpg", "jpeg", "png", "gif", "tiff", "bmp"));
         } else {
             $filename = $post->filename;
         }
     } else {
         $this->delete_file($post);
         $filename = $_POST['filename'];
     }
     $post->update(array("filename" => $filename, "caption" => $_POST['caption']));
 }
コード例 #28
0
ファイル: audio.php プロジェクト: betsyzhang/chyrp
 public function update($post)
 {
     if (!isset($_POST['filename'])) {
         if (isset($_FILES['audio']) and $_FILES['audio']['error'] == 0) {
             $this->delete_file($post);
             $filename = upload($_FILES['audio'], array("mp3", "m4a", "mp4", "oga", "ogg", "webm"));
         } elseif (!empty($_POST['from_url'])) {
             $this->delete_file($post);
             $filename = upload_from_url($_POST['from_url'], array("mp3", "m4a", "mp4", "oga", "ogg", "webm"));
         } else {
             $filename = $post->filename;
         }
     } else {
         $this->delete_file($post);
         $filename = $_POST['filename'];
     }
     $post->update(array("title" => $_POST['title'], "filename" => $filename, "description" => $_POST['description']));
 }
コード例 #29
0
ファイル: JoinAction.class.php プロジェクト: baby-bus/babyweb
 public function save()
 {
     $data = $_POST;
     $job = $data['job_select'];
     empty($_FILES['checkFile']['name']) && $this->error('简历限制最大为2M');
     empty($job) && $this->error('岗位必须选择');
     $data = upload($data, "./Public/Uploads/job_upload/", $this->_config);
     if ($data['error']) {
         $this->error($data['error']);
     }
     $file = "." . $data['upload_url'];
     $subject = "【" . $job . "】岗位申请";
     $body = "【" . $job . "】岗位申请";
     if ($this->send($this->to, $subject, $body, $file)) {
         unlink($file);
         $this->success('提交成功');
     } else {
         $this->error('提交失败');
     }
 }
コード例 #30
0
ファイル: file.php プロジェクト: betsyzhang/chyrp
 public function update($post)
 {
     if (!isset($_POST['filename'])) {
         if (isset($_FILES['file']) and $_FILES['file']['error'] == 0) {
             $this->delete_file($post);
             $filename = upload($_FILES['file']);
         } elseif (!empty($_POST['from_url'])) {
             $this->delete_file($post);
             $filename = upload_from_url($_POST['from_url']);
         } else {
             $filename = $post->filename;
         }
     } else {
         $this->delete_file($post);
         $filename = $_POST['filename'];
     }
     # Prepend scheme if a URL is detected
     if (preg_match('~^((([a-z]|[0-9]|\\-)+)\\.)+([a-z]){2,6}/~', @$_POST['option']['source'])) {
         $_POST['option']['source'] = "http://" . $_POST['option']['source'];
     }
     $post->update(array("filename" => $filename, "caption" => $_POST['caption'], "title" => $_POST['title']));
 }