示例#1
0
function newticket($msg, $params = null)
{
    global $ticketRestParams;
    // handle the upload itself
    $DATA = $validated = false;
    if (isset($_FILES["file"]) && is_uploaded_file($_FILES["file"]["tmp_name"]) && $_FILES["file"]["error"] == UPLOAD_ERR_OK && ($validated = validateParams($ticketRestParams, $msg))) {
        $DATA = handleUpload($_FILES["file"], $msg);
    }
    if ($DATA === false) {
        // ticket creation unsucessfull
        if ($validated && !empty($_FILES["file"]) && !empty($_FILES["file"]["name"])) {
            $err = uploadErrorStr($_FILES["file"]);
            logError("ticket upload failure: {$err}");
            return array('httpInternalError', $err);
        } elseif (!$validated) {
            logError('invalid ticket parameters');
            return array('httpBadRequest', 'bad parameters');
        } else {
            // errors already generated in handleUpload
            return array('httpInternalError', 'internal error');
        }
    }
    // return ticket instance
    return array(false, array("id" => $DATA['id'], "url" => ticketUrl($DATA)));
}
示例#2
0
文件: grants.php 项目: dg-wfk/dl
<?php

$act = 'grants';
includeTemplate("{$style}/include/header.php", array('title' => T_("Upload grant")));
if (!empty($_FILES["file"]) && !empty($_FILES["file"]["name"])) {
    errorMessage(T_("Upload failed"), uploadErrorStr($_FILES["file"]));
}
?>

<form enctype="multipart/form-data" method="post"
      action="<?php 
echo $ref;
?>
"
      class="validate autoprogress">
  <ul>
    <li>
      <?php 
$error = @$_POST["submit"] === $act && empty($_FILES["file"]["name"]);
$class = "description required" . ($error ? " error" : "");
?>
      <label class="<?php 
echo $class;
?>
"><?php 
echo T_("Upload a file");
?>
</label>
      <div>
	<input type="hidden" name="MAX_FILE_SIZE" value="<?php 
echo $iMaxSize;